- Home /
Character returning to start after run jump
Hello,
I have a model and its animations imported from Mixamo. I have successfully did the moving and the jumping part. But while doing running jump (its a separate animation), the character jumps while running but returns to its starting point. The camera which follows the player also doesn't while running jump. Any help is appreciated.
Script:
using UnityEngine;
using System.Collections;
public class PlayerControls : MonoBehaviour {
Animator anim;
void Start()
{
anim = GetComponent<Animator> ();
}
void Update()
{
if(Input.GetButtonDown("Jump")){
anim.SetBool ("isJumping", true);
Invoke ("StopJumping", 0.1f);
}
}
void StopJumping(){
anim.SetBool ("isJumping", false);
}
}
Thank you
Answer by ASPePeX · Dec 22, 2016 at 11:03 AM
It sound like you are doing the horizontal movement in your animation. So i guess your main player object isn't moving at all but the objects within the player object are. If this is the case your, after your running jump animation any other animation returns the object back to its origin since it is keyed that way. This also would explain the camera, since the main player object isn't actually moving.
You shouldn't actually move your player with your animation but either with physics or a script, at least in horizontal space.
Unfortunately, I am not good at animating humanoids, so I took them from the net. I used scripts to move and jump. What I did was that if the character is moving and the Space Bar is hit once, then it would do the running jump animation and go back to the running animation. When it returns to the running animations, it goes back from where I jumped.
Yes, I am doing horizontal movement. I attached the script now so that you can have a look at it. The camera is following the model to which I attached the camera as a child, rigid body, capsule collider and the movement script. You are right in all the ways but using physics, it was a headache to move the player so used transform.Translate and Rotate.
What @ASPePeX is saying, is that your Animation will not work if it moves the character in any kind of horizontal position. I.$$anonymous$$, you need a "standing" animation, that appears like movement. You can find plenty of examples on $$anonymous$$ixamo.