- Home /
player passes through enemy
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
if you have isTrigger checked on for any of the colliders (on the parents) turn those off
if that didnt work try turning off is $$anonymous$$inematic
if neither of the above work, you might have to set it up in a script, use the OnCollisionEnter method or the OnTriggerEnter function
Plus check in Edit -> Project Settings -> Physics that the Layer Collision $$anonymous$$atrix is set up so that different layers collide with each other properly.
Answer by FaizanDurrany · Jul 07, 2015 at 09:50 AM
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.
Hi tnx =) I usually don't use rigidbody becouse i can't regolate the exact position of the object XD, and i am so weak to use it. Now i try to use it using a tutorial.
Answer by ccjbn · Dec 05, 2018 at 03:07 AM
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.
Answer by samra2494 · Dec 20, 2019 at 07:02 AM
Hope this help u..
https://answers.unity.com/questions/537366/prevent-a-character-model-to-pass-through-another.html
Your answer
Follow this Question
Related Questions
Collider break through? 0 Answers
Player(box) randomly falls through objects. 1 Answer
UI - click through image 2 Answers
Falling through the floor issue 11 Answers
Camera go through the wall, help! 0 Answers