problem with character colliding with objects
i have a character created and am using the getAxis code and some animation clips that play when i use the arrow keys to make the character move but when i try getting the character to collide with objects he just passes through them with any collider i try to use. When i add a rigidbody to my character he starts to flip when colliding with objects and cannot get back up. All i want is for the character to stop when he collides with objects and that he cant pass through them or climb over them
here is my code so far on my character
using UnityEngine; using System.Collections;
public class malccontrols : MonoBehaviour {
static Animator anim;
public float speed = 10.0F;
public float rotationSpeed = 100.0F;
// Use this for initialization
void Start () {
anim=GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
float translation = Input.GetAxis("Vertical") * speed;
float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Translate(0, 0, translation);
transform.Rotate(0, rotation, 0);
if (translation != 0)
{
anim.SetBool("isWalking", true);
}
else
{
anim.SetBool("isWalking", false);
}
}
}
is the code that i am using conflicting with the colliders and rigidbody?if it is is there a way to stop this happening?
r u using any script in OnTriggerEnter or OnCollisionEnter?
Your answer
![](https://koobas.hobune.stream/wayback/20220612075050im_/https://answers.unity.com/themes/thub/images/avi.jpg)