Object moving fast keeps "climbing" walls
Hi all, I am still learning Unity and while trying to make something very simple, like a tank moves and there are some walls to avoid it going away, I happened to have this strange result when it hits wall and I keep pressing forward or if nothing is pressed and the speed remains for a while (but having an overal high speed), the tank sometimes collides well but sometimes it starts trying to climb the wall and in fact sometimes it manages that or get upside down etc My current tank is moved by calculating the new position and adding it to the transform position, has a box collider and a rigidbody with a trigger on the bottom to know if its hitting ground or on air (I plan to have ramps and bumps). So far I followed some project tutorials, like the first 5 or so including the Rolling ball, Space shooter, Tank among others projects but of course my idea is slightly different from the Tank project as I havent added constraints to any axys in movement or rotation, could you tell me what am I doing wrong here? thanks a lot beforehand and sorry if question is really silly.
Edit: I think I have somehow isolated the issue, if speed is high it happens always, is it normal?
Answer by $$anonymous$$ · Jun 09, 2017 at 09:38 AM
@MordazaH Try setting collision detection to continuous dynamic on your Tank's rigidbody. This can help trigger the correct events on objects with a high velocity.
Thanks Digland2000 a lot, the fact is the problem seems less frequent with this setting but still happens, is there anything else you could advice?
@$$anonymous$$ordazaH I had a game object that would sometimes not trigger a collision with another collider because of its relative speed and size. It would go right through the object. Setting the collision detection to continuous fixed this for me. If your tank is affected by the wall and not going directly through it then the collision detection might be ok. When you calculate the new position for your tank could you project a raycast and see if you are about to collide with a wall? If yes, then you could change your velocity or put a constraint on the rotation. You could also use oncollisionenter to maybe break your wall apart and decrease the velocity of your tank.
Thank you, as you said tank is affected by wall and not going through it, I think it could be due its size and the wall thickness as well as the ammount of units it moves per frame, and yes I see what you mean, that maybe if speed is high its maybe over for the colission system and I should slow down when the wall is detected with a raycast, I guess I should be casting like 4 rays or so to detect the inco$$anonymous$$g wall and slow down as you suggested, also breaking the wall sounds like a cool idea too. I will do as you suggested and hopefully it will work, thanks a lot =).
I dont think there is more to say on this subject however I will leave the question as unanswered just in case someone could suggest something else.
Your answer
Follow this Question
Related Questions
[CODING|2D] Walls that player is able to break through 1 Answer
How to make wall go up, when you collect cube? 0 Answers
Make the car stop by hitting the wall 1 Answer
raycast going through walls 0 Answers
Why are the 2D colliders not working? 0 Answers