Question by
bathorsthroat · Jan 19, 2016 at 11:35 PM ·
playerscript.gravitynot workingcustom
Gravity not working with character control script
Hello, I have a rigidbody applying gravity to my "Player" but if I walk off an edge the player will remain in mid air and will only fall to the ground if I'm moving the player in a direction?!? my script is c#
public class REController : MonoBehaviour
{
public float speed = 0.01f;
Animator anim;
private string axisName;
int runHash = Animator.StringToHash("Run");
int turnHash = Animator.StringToHash("StandHalfTurnRight");
// Use this for initialization
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
//WALKING
float move = Input.GetAxis("Vertical");
if (Input.GetKey(KeyCode.W))
anim.SetFloat("Walk", move);
if (Input.GetKeyUp(KeyCode.W))
anim.SetFloat("Walk", 0);
transform.Rotate(new Vector3(0, Input.GetAxis("Horizontal"), 0));
//TURNING
if (Input.GetKey(KeyCode.A))
anim.SetBool("turnleft", true);
else
anim.SetBool("turnleft", false);
if (Input.GetKey(KeyCode.D))
anim.SetBool("turnright", true);
else
anim.SetBool("turnright", false);
//RUNNING
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.W))
anim.SetBool("run", true);
if (Input.GetKeyUp(KeyCode.LeftShift))
anim.SetBool("run", false);
if (Input.GetKeyUp(KeyCode.W))
anim.SetBool("run", false);
//RUNNING TURN
transform.Rotate(new Vector3(0, Input.GetAxis("Horizontal"), 0));
Comment
Best Answer
Answer by bathorsthroat · Feb 17, 2016 at 05:00 PM
Got it for anyone with the same dumb problem. I just needed to add the character motor
Your answer
Follow this Question
Related Questions
Copy collision object position (Or just "fly" a little bit) 0 Answers
Changing Color Of Image not working with non-default colors. 1 Answer
The player falls down a ladder 0 Answers
Bool won't change?,Bool wont change to false 1 Answer
None, not even the most simple scripts work!!!! example... 0 Answers