- Home /
Detect collisions without messages?
Hello. Anyone have a method to detect collisions without using messages functions?
In other words, do something like:
void Update()
{
this.Move(movement);
if (rigidbody.enterCollision)
this.Move(-movement);
}
Instead:
void Update()
{
Move(movement);
}
void OnCollisionEnter(Collision collision)
{
Move(-movement);
}
I know that Update has more calls per second that the physics engine, but, maybe exist a elegant solution for implement the first code. Cheers!
PD: Im testing this with a Pong remake, thus, CharacterController dont work for me because his collider isnt a box.
Collision data can be gained ONLY from special functions.
Not always... Example, I can use raycasting without using messages... Although in that case, I wouldnt use a rigidbody...
You could write your own collision detection, what's the point? Are you trying to make some super-optimized Pong game?
Answer by DaveA · Aug 17, 2013 at 10:58 PM
You don't need a character controller, just a rigid body. Collider can be any shape. I don't see any good reason to remake the collision system except as an academic exercise.
I have to! With a rigidbody+collider, when I move using transform.position, obviously not collide! Only sends the message OnCollisionEnter... The problem is how with this method can I "crash" with a wall??
Your answer
![](https://koobas.hobune.stream/wayback/20220613112420im_/https://answers.unity.com/themes/thub/images/avi.jpg)