ok so i got my animation to work with my touch screen buttons finally! lol so my character runs left and right and idle,my problem is when running left and right he run at an angle more so turning right…i want him to just run left or run right preferably on the x -axis is the possible to do?
anyone?
Can you provide more details? Are you using Mecanim or legacy? By running left and right, do you mean strafing (side-stepping), or rotating 90 degrees and running “forward” in the new local orientation?
im using mecanim rotating and running forward would be more ideal as strafing would look robotic to me for this situation
Are you using turning animations (like in the Locomotion Starter Kit), or manually rotating the transform?
If you’re using turning animations, here’s one solution:
-
If you have a locomotion blend tree that includes running forward and turning, remove it.
-
Create a state machine with three clip states:
- RunForward: plays the run forward animation
- TurnLeft: plays an exact 90-degree left turn
- TurnRight: plays an exact 90-degree right turn
-
When it’s time to turn left, just transition from RunForward to TurnLeft. Make sure it’s atomic and runs all the way to the end to guarantee that TurnLeft does the full 90 degrees. At the end (exit time), transition back to RunForward.
-
Same for turning right.
If you’re manually rotating the transform, just make sure to rotate it exactly 90 degrees, perhaps in a coroutine.
ok i see what your doing there but maybe i have to import new animations because the ones that came with the character are part of a running animation and inside the animation is run left and run right so he is running and turning at the same time does the locomotion starter kit have what you are suggesting?
You could always download the Locomotion Starter Kit to check for yourself. It’s free.
Anyway, animations in the starter kit also run while turning. That shouldn’t be a problem, though, if you use the state machine I suggested in my previous reply.
now how my game is set up its like a 2D structure in 3D enviroment(obviously lol) the character can hold Idle, run left or run right and back to idle when stopping or changing position…if he is to run forward he would be running towards the camera and i dont want that ya see? now i messing with what you said in previous previous post but thought id throw that out there seeing if you had insight on that
Sounds like you’re designing a 2D platformer. If so, maybe this tutorial series will help: http://forum.unity3d.com/threads/186908-Unity-Tutorial-Creating-a-Scroller-Platformer-Game
It includes a section on Mecanim, too.
i actually got it how i want it now i meant to write this last night lol…ok so on the final note of this how do i add speed to the animation ive tried adding force, using a float variable but maybe my placement is wrong cause he still move some one slow
Since you’re using Mecanim and presumably root motion, increase the state’s Speed. Or, to get more sophisticated, create a blend tree with the same animation at different speeds, and blend between them on a float parameter.
Thanks So much man i really appreciate your help!
Happy to help!
ok ok i lied lol when i mentioned speed i dont want my animation to be faster per se but when the character run left or right im looking for him to move faster IN that direction
If you’re using root animation, you need to edit the original animation so it moves faster. If you’re scripting motion (e.g., CharacterController.Move()), then you just need to increase the offset. Check out that tutorial series for more help.