- Home /
Question by
Gamechanger19 · Apr 24, 2016 at 07:34 AM ·
scripting problemcollisionscriptingbasicscharacter controller
Character Controller NOT COLLIDING.
I tried searching for a lot answers and videos that could solve my issue but none of them seem to work. I know there's something wrong in my script, but i don't know what exactly is making my character pass through every collider. This is my script. Sorry im new to this so it might be a dumb mistake.
using UnityEngine; using System.Collections;
public class Player : MonoBehaviour {
public Animator anim;
public float movex = 5f;
Vector3 movement = new Vector3(0,0,0);
public CharacterController irena;
public bool attacking = false;
public float gravity = 10f;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
irena = GetComponent<CharacterController>();
}
// Update is called once per frame
void FixedUpdate () {
movement = new Vector3 (Input.GetAxis ("Horizontal"), movement.y, Input.GetAxis ("Vertical"));
movement.y -= gravity * Time.deltaTime;
irena.transform.Translate (movement * movex * Time.deltaTime);
if (Input.GetKeyDown ("1")) {
anim.Play ("WAIT01");
}
if (Input.GetMouseButtonDown (2)) {
anim.Play ("WAIT04");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How can i make my character jump and slide on command? 0 Answers
Making the collider change after being instantiate 2 Answers
Why is my collision script not working? 1 Answer
Can you trick a Ui Button that it is being clicked with code? 3 Answers
Limiting rigidbody physics influence on another rigidbody 0 Answers