I’am creating a game where player can change the game object using mouse wheel and he/she have to pass through the incoming obstacle without colliding by using keys WASD
The problem I’m facing here is collision between obstacle and player is not properly detected when obstacle is moving as shown in below videos.
Collision between player and object is properly detected when player collides with obstacle at the edges as shown in video-1
Collision between player and object is not detected when player is colliding with obstacle completely as shown in video-2
Collision is working as expected in both cases(colliding with edges and colliding completely with the obstacle) when I stop moving obstacle by commenting line number 110 obstacle.position.z += 0.05; and start moving my player towards the obstacle as shown in video-3
What may be the reason for this behaviour and how to solve this?
NOTE: Click on game screen once to move game object
It would be really helpful if someone helps me in solving this…
I would not change position of player but change the linear velocity instead. I think changing position each frame, when using a physics engine, is not a good solution in this case.
@Cedric In order to add linear velocity to my obstacle I need to change the mass property of my obstacle which was zero earlier. Now when I set my obstacles’s mass=1 & restitution=0 it is bouncing and falling off the ground. Even with ground restitution=0 same thing is happening.
How can I make Obstacle to stand and move without falling ?
@Cedric This doesn’t solve my root problem and also creates one more problem, i.e, now my player(sphere) cannot pass through the hole in obstacle as shown in the below video
You can use a compound with multiple boxes making it dynamic.
or leave it as a static mesh impostor (with mass = 0)
I don’t think it’s a good idea to move the static world around the player: I’d suggest to move the camera and the sphere and keep everything else static.