- Home /
Moving gameobjects with easing
Im trying to make move commands similar to the one in the game 'Geometry Dash' When a move command is activated, a target object is moved a certain distance in the x and y axis within a specific time(seconds). Easing can also be applied to control the acceleration/deceleration of the object while it is moving.
Move commands need to be able to stack with each other
I have a MoveCommand class that calculates the current displacement every fixed update for each move command.
An example of the calculation i am currently using in the MoveCommand class:
//The 'time' variable is between 0.0f to 1.0f
//this is just an example to show different easings
displacementX = time * moveDistancXe; //for linear easing
displacementY = (time * time) * moveDistanceY; //for quadratic in easing
targetObject.transform.position = new Vector3(displacementX, displacementY, 0.0f);
How do i go about taking all these MoveCommand(s) and applying the displacement to the target object, since there can be multiple MoveCommands affecting the same object? Or is there another much way to this?
tldr - I need a way to move objects when a command is given(i know how to do the easing part). I have no problems when working with a single command, but there can be multiple commands affecting the same object at once, resulting in each one of them overriding the other.
I'm afraid not a lot of us will understand what exactly you are trying to do here and where you are stuck. I myself never played Geometry Dash. We will need more specifics and probably a good idea to post the scripts you have the problem with. Posting pictures can help a lot, so kudos on that.
One thing I can tell you is that you probably don't want to calculate any sort of displacement every frame. You want to do that in FixedUpdate.
Thanks for the advice, i'll try to explain my question clearer
Answer by TheMannyzaur · Sep 24, 2017 at 02:59 PM
Vector2.Lerp can be used for easing. try looking it up on Scripting Ref
I know how to do the easing parts, what i don't know is how to apply multiple easings that stack with each other to the same gameobject
@GenericToast can you explain further because I havent played Geometry Dash
Each $$anonymous$$oveCommand calculates a displacement using an easing formula. I want to take these displacements from multiple $$anonymous$$oveCommands, and apply it to the position of a single gameobject
Your answer
