You should use lerp as — mentioned... <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">
lerp(currentY, targetY, %distanceToMove)
For example:
Every tick >> Set Y to lerp(AirplaneRender.Y, Mouse.Y, 0.1)
If you want it to move faster, increase the third value, otherwise, decrease it.
I tried many combinations and that was the first. My plane moved allong with the mouse sometimes (like before) and sometimes not at all.
That is really bad solution for several reasons. Do look into lerp (just check the space shooter example project).
Actually that works perfect for me. I can also adjust the speed by modifying the +2 or -2. And ofc set it to a var if i want and let the player set it.
Anyway, it works so its fine for me <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">
nickdtsag
Glad you found a solution that worked. I can see the benefit of your solution compared to the Lerp function. It appears you want the sprite to move at a constant rate along the Y axis whereas the Lerp function would cause the plane to accelerate more the farther from the Mouse Y it is. Just for fun, I thought I would give you an optimization for your method. You can cut your action count in half (I know, 1 action isn't a big deal but this function can help in a lot of other ways as well) by using the conditional operator. I will post a link to the operators section at the bottom so you can read about what it does.
[attachment=0:ydawftqw]Capture.PNG[/attachment:ydawftqw]
This single action will do the same as your 2. Just change one of your conditions to not equal then replace the action to set the AirplaneRender.Y to the following:
AirplaneRender.Y + (Mouse.Y - AirplaneRender.Y > 0 ? 2 : -2)
https://www.scirra.com/tutorials/77/nat ... uct-2#h2a0
Exactly!
And your tip works perfectly as it was before with 2 events! Awesome!
Thank you all for your time!