- Home /
Collision Detection Problem
In my simple 2d game, when ever my rigidbody starts moving with transform.translate or rigidbody.addrelativeforce whenever it starts colliding with another object, say a cube it should stop instantly when it touch it but it dont,it go halfway through the object and stop there, when i stop moving it, it goes out of the object like an elastic motion, how can i fix this ? and make the collision solid? i used transform.translate rigidbody.addrelativeforce the object has rigidbody not kinematic the cube has collider only , tried with kinematic rigidbody also the same.
Answer by midomido · Jun 30, 2013 at 08:22 PM
A simple solution was to use Character Controllers, only then the collision was solid
Answer by LucasMars · Jun 30, 2013 at 08:00 PM
This is worth checking out:- http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.MovePosition.html
Transform.Translate ignores objects and goes straight through them.
You did not state what type of code so here are the main ones:-
private var speed : Vector3 = Vector3 (3, 0, 0);
function FixedUpdate () {
rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime);
}
or
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
private Vector3 speed = new Vector3(3, 0, 0);
void FixedUpdate() {
rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime);
}
}
I hope this helps
Sorry, but this is exactly the same effect. Its not a Solid Collision
Your answer
Follow this Question
Related Questions
Collision not working 3 Answers
Collision detection not working properly with 2D sprites 1 Answer
collision wont work 1 Answer
Best practice for OnTriggerEnter detection 1 Answer
Need advice on non-realistic bullets collision vs distance 1 Answer