I have this formula for an object to decelerate as it nears its target:
Pos( "Active" )+(Mouse-Pos( "Active" ))*0.1
How do I reverse this so that it accelerates until it hits the target and then stops?
Thanks!
Printable View
I have this formula for an object to decelerate as it nears its target:
Pos( "Active" )+(Mouse-Pos( "Active" ))*0.1
How do I reverse this so that it accelerates until it hits the target and then stops?
Thanks!
I had to use a few actions, but I think it's the best way to do it...
I was hoping not to use angles and distances. After a bit of looking around I found this:
+key not pressed
-->set dx,dy to xpos,ypos
-->set t to 0.0001
+key pressed
--> set dx,dy to dx,dy+(t*(tarx,tary - dx,dy))
--> add t to t (for exponential movement)
+t > 1.0
--> set t to 1.0
Thanks anyway!
Can you post the mfa of what you found?
I have to agree with you Eliyahu, it seems like a good solution. I'm not saying what you found SolarB, is not as good or better. Just would like to see both!
Example:
Attachment 7104
I think it's a form of interpolation. The reason I don't want to use distances and angles is because my program is already under load and these add extra strain, so I'm told.
As for cleaner and shorter, well, you be the judge.
Anyway I like your method Eliyahu and in any other situation I would probably use it.
What a weird solution...lol. But if it works, that's fine! It's all about getting it into your application easily.
As far as slowing down your program, there will be absolutely no noticeable difference between mine and yours. These calculations happen so quickly in comparison to the other things your application has to handle.
What slows MMF2 is when you have excessive graphics, fastloops going for thousands of loops and performing on multiple objects, and just plain lots of objects.
Mathematical operations are essentially nothing.
Both are good examples, but how would you slow down the acceleration in yours SolarB. It seems to me that when you click, the object moves pretty fast toward the mouse pointer and I can barley see the increase in acceleration.
Eliyahu: Yes I have > 500 objects so each of them doing trig and setting angles (especially setting angles) does slow it down a little (need precious FPS).
KliK-It: Just set t to t*0.whatever
You shouldn't need to set angles, since you can almost always operate in X and Y separately.
Almost always. This is a situation in which X and Y need to be moving together. When they are decelerating, they can move independently. Accelerating is entirely different, since the movement of one depends on the position of the other.