- Home /
Question by
JudgeDredd · Feb 17, 2014 at 03:23 AM ·
cameracollisiondetectionthird-personaction
Jittery Collision Detection
I am making a third-person action game and everything went smoothly until I added a cube in my game to test collision/jumping and the collision started jittering/glitching when I continuously walk into it or jump into it. The player is currently a capsule and I tried adding a box collider to it with no luck. Here is the controller script:
#pragma strict
var moveSpeed : int;
var rotateSpeed : int;
var jumpSpeed : int;
var floor : Transform;
private var isFalling : boolean = false;
function Update()
{
if (Input.GetKey(KeyCode.W))
{
transform.position += transform.forward * moveSpeed * Time.deltaTime;
}
else if (Input.GetKey(KeyCode.S))
{
transform.position -= transform.forward * moveSpeed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
transform.eulerAngles.y += rotateSpeed * Time.deltaTime;
}
else if (Input.GetKey(KeyCode.A))
{
transform.eulerAngles.y -= rotateSpeed * Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Space) && !isFalling)
{
rigidbody.velocity.y = jumpSpeed;
isFalling = true;
}
}
function OnCollisionEnter(collision : Collision)
{
var object = collision.transform.gameObject;
if (object.name == floor.name)
{
Debug.Log("Colliding with ground");
isFalling = false;
}
}
Comment
Okay so I solved the jitter of regular walking/jumping using FixedUpdate ins$$anonymous$$d of Update but when I jump into the cube it still sticks and I have to stop moving to let it fall.
Your answer
Follow this Question
Related Questions
Prevent camera from going trough objects? 0 Answers
Camera Collision Didn't Work. Please Help me... 2 Answers
3rd person camera through wall 2 Answers
3rd person camera that avoids objects 0 Answers