Moving an actor/changing directions/where touch is pressed. HELP?!
Heatherrrr
Member Posts: 1
This may be a bit ambitious, but I would really love some advice on how to make this happen
I want the main actor to move according to where touch is pressed on the screen. I have animations for my actor to move in all 4 directions. So if the touch is pressed to the left of the actor, I want the left animation to activate while moving the actor to the left. And so on.
But here is where my true problem comes in. If touch is pressed at an angle of the actor I want the actor to move in an L shape vs in the angle of the touch and I want the animations to go along with the direction the actor is moving in. So if touch is pressed up-left of the actor, the actor will move left (with the left animation) and then up (with the up animation). Then if touch is pressed again while the actor is still moving from the previous touch, I want it to go towards the new touch instead.
If anyone can help that would be just peaches Thank you.
I want the main actor to move according to where touch is pressed on the screen. I have animations for my actor to move in all 4 directions. So if the touch is pressed to the left of the actor, I want the left animation to activate while moving the actor to the left. And so on.
But here is where my true problem comes in. If touch is pressed at an angle of the actor I want the actor to move in an L shape vs in the angle of the touch and I want the animations to go along with the direction the actor is moving in. So if touch is pressed up-left of the actor, the actor will move left (with the left animation) and then up (with the up animation). Then if touch is pressed again while the actor is still moving from the previous touch, I want it to go towards the new touch instead.
If anyone can help that would be just peaches Thank you.
Comments
What you might want to do is change the speed of the interpolate based on the distance it's travelling a long one axis because at the moment it takes 0.5 seconds to travel the line regardless of how long the line is and on a short line it will move slowly.
EDIT: I've noticed a problem where if you move the mouse while it's moving it changes direction so have deleted it and uploaded a new version in the post below
It uses an invisible actor over the scene which I've called Trackpad. When it's pressed it stores the x and y position of the mouse/touch in two game attributes, and then moves the character to those values.
It only took like 2 seconds to create so it's not a problem if it's not what you're after
EDIT: I updated it some more and attached a new version in the post below.