Interpolate Instead of Move
KickingBehinds
Member, PRO Posts: 49
I've had the dreaded situation where my frame rate has suffered becuase I have too many Move functions so I need to replace them with Interpolate functions.
I've read many pages on this forum which addresses this but I can't find a clear solution to my problem.
The main issue I have is getting a constant speed as many of the actors in my game are moving to other actors which are also moving. I understand that time = distance/speed (I already have the distances calculated), however whenever I apply this the actor moves slowly then quickly accelerates.
If anyone can clearly explain what I need to do get a constant move speed using Interpolate functions that would be greatly appreciated.
Comments
Do you have the interpolate on linear?
Lump Apps and My Assets
Yes.
Are you interpolating position.x to position.x+100 or something similar? If so, the actor will zoom off like it has somewhere vitally important to be. Make a self attribute, ideally a real attribute, and just before each interpolate set that attirbute to the current position. Then interpolate the position using the attribute.
i.e. Interpolate self.position.X to self.startposition+100
Perhaps that's your issue?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I have tried creating real self attributes like you said (this was also suggested in another thread), but no luck. I'm obviously doing something wrong.
In my game there are lots of actors moving around so the distance that the actor has to move to is constantly changing, I'm wondering if this could be a problem.
Try making a new project and adding just one actor to it. Can you get that one to move as you expect? If not, post that pared down project and we can see how you're doing it and hopefully what's going wrong.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I just made a new scene with a new actor.
I have an actor (Actor 1) and it needs to move to Spot 1.
I already have an attribute which is "Distance from Spot 1" (using the magnitude formula) which calculates how far away Spot 1 is at all times.
I have created two new real self attributes within Actor 1, "New X" and "New Y".
I know I can't use the self.position.X and self.position.Y in the Interpolate function (becuase the actor zooms off), so where I am getting confused is how I use these two new self attributes (New X and New Y) into the Interpolate function. Also, how these new self attributes relate to self.position.X and self.position.Y.
I'm still having no luck working out a solution to using Interpolate instead of Move and getting the actor to move at a constant speed.
Can anyone tell me if Change Velocity or Accelerate are better for the frame rate than Move?
If you have the X and Y positions of Spot 1, is there any reason you can't just interpolate your actor to those positions?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
The problem is moving at a constant speed, no matter how far away Spot 1 is.
If you want something to go in a constant speed in a certain direction -- you want to use a change velocity behavior.
You are already working out the speed though - if you have the distance and know the speed you want it to move (say, 200px/sec) then you have the time to put in the duration box.
(I agree that change velocity is a better option, but interpolate is still viable and was what you specifically asked about )
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Interpolate can mess with collisions mind, set max speed and use accelerate with a high value...
Acceleration means changing speed over time. @Shouting At Horses is asking for a constant speed.
Attached is one example of how to use the Change Velocity behavior and make it act like a move behavior.
Thanks for that, I actually ended up with almost the exact same formula as in your attachment when playing around with my game last night!
You are welcome. Glad you got it figured out.
Any chance you can change your name so that it does not contain spaces? Having spaces messes up the system.
You could use underscores to make your name Shouting_At_Horses.