Hi people,
in my scene i have 2 object the player and the enemy.
the player and the enemy have a lot of child and every child have a lot of child.
every child have a box or spere collider.
the player and the enemy have a rigidbody(no gravity and kinematic)
My question is why player passes through enemy ??
how i can evitated this??
Note:i move and rotate player and enemy using transform.position and transform.rotate
Hello AntoPolizzi
the problem you have is that you are using transform.position
and transform.rotate
to move objects. you are actually changing the object’s position in the world coords which means it will ignore any physics. it is just like moving objects from within the editor. if you have rigidbodies attached to both, the player and the enemy why not use Rigidbody.AddForce
?
if you still don’t want to use Rigidbody.AddForce
then you can also use CharacterController
. there are some really good tutorials on youtube for moving the player.
if u still dont get it i am happy to explain more.
Regards Faizan.
I had a similar problem. In my case it seemed as though the vector3, which I named movement, I used to make changes in the x and y coordinates was bringing the objects back to it’s settings after being pushed. I put movement = transform.position; at the beginning of my UpDate() method, before my If(Input…) conditions. That way the actual position matched the vector3 position I was going to manipulate.
Hope this help u…