Question by
Creationary · Jul 15, 2016 at 07:32 PM ·
collisionbugglitchcollision issues
collision glitch
im useing a custom made character controller but whenever i hit a wall with a collider the player moddel starts humping the wall and if the wall is thin enough it can even glitch through the wall. Does anyone know what is happening?`using UnityEngine; using System.Collections;
using UnityEngine;
using System.Collections;
public class Player_Movement : MonoBehaviour {
public float walkSpeed = 5f;
void Update () {
bool forward = Input.GetKey (KeyCode.W);
bool backward = Input.GetKey (KeyCode.S);
bool left = Input.GetKey (KeyCode.A);
bool right = Input.GetKey (KeyCode.D);
if (forward)
{
transform.Translate (Vector3.forward * Time.deltaTime * walkSpeed);
}
if (backward)
{
transform.Translate (Vector3.back * Time.deltaTime * walkSpeed);
}
if (left)
{
transform.Translate (Vector3.left * Time.deltaTime * walkSpeed);
}
if (right)
{
transform.Translate (Vector3.right * Time.deltaTime * walkSpeed);
}
float mouseX = Input.GetAxis ("Mouse X");
transform.Rotate (0, mouseX * 5, 0);
}
void OnCollisionEnter (Collision tag)
{
if (tag.gameObject.name == "Wall")
{
Debug.Log ("Wall Detected");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
3D Jumping Collision Bug 1 Answer
Why are my objects falling down?,Why are my objects moving when i play game. 1 Answer
Background showing in shadows and Post Processing 0 Answers
Multiple colliders BUG 0 Answers
How do you call a function once 2 Answers