- Home /
Question by
FreddyFred · Apr 21, 2014 at 03:39 PM ·
Animated rotate on X Axis
First of all I want to apologize for my english.
I got an walking cycle animtion that moves around X axis.When it reaching the specified limit its goes back where is starts,The only problem its walking backward. I want that the object will ratote 180 so it will looks like the objact will walk in the right direction instead off moon walking
Im using C# script 
capture2222.jpg
(77.0 kB)
Comment
Don't be lazy. Copy your code and paste it here using the 101010 button ins$$anonymous$$d of posting an image of your code.
{
public int moveSpeed = 140; //per second
Vector3 computerDirection = Vector3.left;
Vector3 moveDirection = Vector3.zero;
Vector3 newPosition = Vector3.zero;
void Start ()
{
}
void Update ()
{
Vector3 newPosition = computerDirection * (moveSpeed * Time.deltaTime);
newPosition = transform.position + newPosition;
newPosition.x = $$anonymous$$athf.Clamp(newPosition.x, -101, 126);
transform.position = newPosition;
if(newPosition.x > 7)
{
newPosition.x = 7;
computerDirection.x *= -1;
}
else if(newPosition.x < -7 )
{
newPosition.x = -7;
computerDirection.x *= -1;
}
transform.Rotate(Vector3.right * Time.deltaTime);
transform.Rotate(Vector3.up * Time.deltaTime, Space.World);
}
Your answer
Follow this Question
Related Questions
Mega-fiers morphs Pause ? 2 Answers
Change Animation According to Direction 1 Answer
Imported animation doesnt play if assigned to parent 1 Answer
Saving out animation changes 1 Answer
Camera animation 1 Answer