A
A
Andrey Begin2019-06-27 00:02:11
C++ / C#
Andrey Begin, 2019-06-27 00:02:11

Object collision without RigidBody2D?

There is an object that I control with arrows. Physics is not suitable for him, since this is not a platformer.
I need to trace the contact with the walls on the sides.
OnCollisionEnter doesn't help at all. I hang the collider on the walls and on the moving object itself, but it does not read the collision. Is there a way to determine contact? Manually calculating coordinates through code is not an option. Since in addition to the walls there will be even more complex objects with different angles, with which it will be necessary to calculate the collision in the future

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dinner, 2019-06-28
@Dinner

You can add a Rigidbody, but turn off its gravity - then the object will not fall down, but move normally, and you won't have to suffer with colliders. Only physical functions like AddForce will not work very correctly, it will also have to somehow block the rotation through the code - since the object will be considered in weightlessness, when colliding with other objects it will rotate. I added in Update:
transform.rotation = Quaternion.Euler(0, 0, 0);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question