- Home /
Two GameObjects "Pushing" eachother
Hello,
I've got an issue: I've got a player and an enemy in a top down dungeon crawler game.
Whenever the enemy runs against the player, the player gets pushed backwards. The same happens when the player runs against the enemy. Is there a way to prevent this from happening? I want both the enemy and the player to be "unpushable" when running up against eachother.
I already tried playing with the mass/drag/angular drag of both objects, but it didn't help. If I increase the mass of the enemy by for example 100, it is obvious that the enemy wont be pushed backwards because he is too heavy. But instead pushing the player will become even easier because the player weighs nothing compared to the enemy.
Thanks in advance
Answer by EvansGreen · Jan 12, 2013 at 11:28 PM
You should use the "Character controller" component for both, your player, and your enemy, that should prevent the physics/related interaction and at the same time avoiding the "ghost" effect that you're complaining about.
Don't just use simple colliders for that, or you'll enable the use of phisics between them.
I never really used CharacterControllers. I'm using box colliders to check collision etc. After reading your answer, I decided to replace the box collider of the player with a character controller. The character is now able to run through walls and other objects. Do I have to change/add more properties to the player?
Your answer
Follow this Question
Related Questions
Why do Instantiated GameObjects Colliders only work on player i am controlling,nothing else? 2 Answers
Objects with colliders going through walls and each other. 3 Answers
How to reset a scene from collision with a GameObject? 0 Answers
Detect cloned object detection once 0 Answers
Change size and mass on collision 1 Answer