- Home /
colliders and physics
so im sure this is a rather simple problem
but heres what i have
i have a player with the basic FP controls and then i have a custom made AI
now they both have their respective colliders, i believe the character controller has a default collider
now my bear AI
i have it set up so that if a player enters his range he will pause and then pursue the player and when the player enters his attacking range he will stop and attack the player (because of the way i want my game i have it so if the bear catches you you are owned which means when he does i have it so i locks down the players controls and camera[so they can watch helplessly as they are turned into a human chew toy])
now my problem is if the bear starts chasing me and i try to run away he will eventually catch up to me and i enter his attack range when that happens my controls do lock out however for some reason my player continues to move for like 5 feet then stops even though the player has no control and because of the way i have it, i have to have the bear stop when he attacks
Can you show the bear's code? I think I can help you to make the bear stop when he attacks.
its like 200-300 lines of elaborate and poorly organized code plus 7 links to world interactions
-he stops, thats easy, its the player that continues moving -since i couldnt fix the player from doing that i made a work around that makes the bear move again if the player leaves his attack sequence
Answer by jpmythic , developer, programmer, technician · May 26, 2011 at 01:33 PM
I believe that has to do with Physics.. The forward momentum of the player needs to be zeroed out when you stop him. This can be done by getting current velocity and reversing it and adding that as a force to the player.
Just started with Unity so cant give you the specific code, but I dealt with this issue with another engine.. The Physics friction can also slow them down as well.