An example of making an object swing like a pendulum using sin/cos.
In reference to: http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=155706&gonew=1# UNREAD
Printable View
An example of making an object swing like a pendulum using sin/cos.
In reference to: http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=155706&gonew=1# UNREAD
It stops too suddenly, that is unrealistic, it should slow down then accelerate in the other direction and move back, otherwise excellent job.
Note: You can use Sin/Cos to do this.
He used sin/cos... I haven't got the chance to look at it, but It sounds good if you used sin/cos correctly! ;)
I just noticed something with this. The object gets placed in an absolute position before it starts as seen here.
Set X Position to 320+(Sin((AngleTo( "Active" ))-90)*Distance( "Active" ))
How about adding 2 more alt. values (Value D, Value E) named Pos X and Pos Y. Use 'Start of frame': Set Pos X(Value D) to X("Active"), and Set Pos Y(Value E) to Y("Active"). Then in the always event, use this instead.
Set X Position to Pos X( "Active" )+(Sin((AngleTo( "Active" ))-90)*Distance( "Active" ))
This way, the swinging object is not always bound to a specific position on the screen before swinging. It would have its own starting position.
I know this is something a little bit extra, and probably not necessary for this example, but it helps. ;)
Check my reply in the same topic mobichan is reffering to, to see how you can do the yposition with sine too.