Obstacle Colliders

Having remarkable trouble with the collisions with the obstacles. Since the floor is moving, it needs to collide with Toady and get stopped. It seems whatever I do, either Toady goes flying off the screen, the obstacles go flying, or Toady goes right through the obstacles.

This boils down to, which parts should have non-trigger colliders and which parts should have rigidBodies? Also do I need to put constraints on anything?

How are other people getting along on this part?

[Edit] Still can’t figure this out, but changed my mover motion from Transform.Translate to Rigibody.MovePosition. Still not working though…

This took a while for me and now struggling to remember all that I did and I’ve not tidied the code yet!

Possibly Contains Some spoilers

How I set up the obstacles (with constraints) meant that the player was knocked off kilter by the physics engine exacerbated as the environment would move based on what keys were pressed even when the player was ‘stuck’ or knocked sideways so the player would end up falling off the screen or disappearing off to the side.
To stop this I then adjusted the move script not to move the environment if the player wasnt where it was supposed to be.

Hope that helps a bit.

Hmm, so you had to code the movement to account for the collisions, you couldn’t find a way to let the physics engine handle it? I have been avoiding trying to script this instead of figuring it out with colliders and rigid bodies.

I tried all sorts.


The environment movement assumes the player doesnt move.
The physics engine is moving the player when the collision occurs (or not if the movement is too fast/big and the player appears to go through…)
Don’t see how else to do it.
One reason I haven’t attempted the river and jumping on boats and then moving the player with the boat is my brain cannot handle it as the player isn’t suposed to be moving, everythingelse would have to.
If I wanted all these things I’d code the movement to be moving the player not the environment…

My thought was treat it as if you are trying to move the environment around the player. The player is the obstacle, need to navigate around it. The environment components have kinematic rigidbodys. I thought I could find a way to have the parts collide with the player. Now that I think about it, only one part would collide with the player at the time, prevent them from moving as a unit. Anyhow I hit many dead ends here. I agree, having the player move would make more sense for this.

Working with the world moving instead of the player definitely requires a shift in thinking and does present some new challenges that you may not have encountered before!

Here’s some food for thought that might help (without completely giving the game away):

Have you thought about using raycasting to see what’s around the player?

2 Likes

Privacy & Terms