Player Getting Pushed Off Ground/Grid by Enemy

Hello,

If I let the enemy push my player then the player gets pushed off of the ground and into the tilemap.

image

Hi Anthony,

The problem is very likely that we are manipulating the position of our game objects directly. We are circumventing the physics simulation.

What you could try is to move the player and the enemy via velocity or AddForce in the FixedUpdate method. Look these things up in the API. In Update, you can use bools which you set to either true or false depending on the user input. And in FixedUpdate, you could use those bools in if-statements.

Hi Nina. I used the code that Rick had in the lecture. Should I move it to Fixed Update from Update?

Yes, try what I described. You can move a part of Rick’s code but you’ll also have to write a few lines.

You can close this. The issue I had was irrelevant once I added the death throw. Thanks.

Privacy & Terms