So this has been nagging me for a while and its probably a simple fix, but I have no idea how to do it. So what’s happening is I set the position in my animation tab then play the animation when a certain key is pressed and update the position of the player. I have even tried to set the cube as a child of an empty parent object (maybe I’m doing it wrong), a video may be of help ![]()
Scene view
This is the script (written in C#):
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
//Uses animations based on input and if no key is pushed then you stay idle
void Update() {
if(Input.GetKey(“w”))
{
animation.Play(“CubeMovementForward”);
}
else if(Input.GetKey(“a”))
{
animation.Play(“CubeMovementLeft”);
}
else if(Input.GetKey(“s”))
{
animation.Play(“CubeMovementBackward”);
}
else if(Input.GetKey(“d”))
{
animation.Play(“CubeMovementRight”);
}
else if(Input.GetButtonDown(“Jump”))
{
animation.Play(“CubeMovementJump”);
}
}
}
(The position set is the same start position for all levels)
And a video to show
