Change animation based on finger drag?
Quick question. I have been trying to figure out how to do this to no avail. I have an actor that is controlled by two buttons left and right, the actor moves left and right depending on which is pressed and he also has corresponding animations for left and right... easy.
but..
I decided that I want a 1 finger touch slide controls for left and right, so I constrained the actor to another so that instead of pressing 2 buttons you can slide your finger back and forth to control right left movement.
The problem: How do I get my right, left animations to work with this slide control? So that when you slide left his left animations work, and when you slide right his right animations work...
Any help as always is greatly appreciated!
Rob
but..
I decided that I want a 1 finger touch slide controls for left and right, so I constrained the actor to another so that instead of pressing 2 buttons you can slide your finger back and forth to control right left movement.
The problem: How do I get my right, left animations to work with this slide control? So that when you slide left his left animations work, and when you slide right his right animations work...
Any help as always is greatly appreciated!
Rob
Comments
Maybe if I ask in a different way?
Is there a way to use counting up and down as a trigger for something (like my animations) So that when ship is being dragged right the right animations fire... and if dragged left the left animations go. I thought maybe this could be done with the X position of the actor... but I couldn't get that to work.
There has to be a way to do this right?
Then have a rule with that says something like.
if Direction is Left
Play the left animation
Otherwise
Play the right animation
Just a thought...
As I type that out I'm also thinking you could just check the value of your Linear.Velocity X in two rules, like this:
If Linear.Velocity X > 0 (that's moving right)
Play the right animation
and do a second rule that says:
If Linear.Velocity X < 0 (that's moving left)
Play the left animation
Use the following if you'd like to constrain an actors movement to another:
constrain linear.velocity.x To: (target.pos.x - self.pos.x)*20
Then do the same for y-axis.
Constrain is just a behavior that continually changes an attribute as fast as programmatically possible. Basically, a never ending change attribute. Constrain is in no way related to the physics engine.
Physics wasn't working because you were constraining an actor's position. Moving an actor and changing its position are not the same. A position of an actor is nothing more than its x and y coordinates.
Movement of an actor includes information such as position, acceleration, velocity, vector and so on. This information needs to be present for physics to function properly.
Editing an actors position will always disrupt physics.
Remember, there is nothing magical going on behind the scenes... it's all math.