- Home /
Enemy Character Controller
Hi,
I'm looking for some advice, I've got an enemy character with a character controller attached to him and he patrols some waypoints and if the player comes into range he will attack ether by running at you, squatting and shooting or he will shot at you while lying down.
My problem is when the player shoots at him while he is patrolling thats fine because the raycast hits his character controller capsule, but when he squats or is lying down because the character controller capsule stays upright you can kill him by shooting above him and the raycast will detect the capsule.
So any suggestions how best to go about this?
you could try some trickery and check if the hit is above the center of the collider, if so then ignore hit. If the contact point is under the center of the collider , do some damage =]
try moving the capsule of the CC when the squat animation isPlaying. :)
Thanks for your advice, some trickery by reducing the returned hit hight if squat is true could be the solution.
$$anonymous$$oving the CC down when he is squatting moves the character down to as he's the child.
Answer by Justcool25 · Jul 25, 2012 at 07:03 PM
All you have to do is either rotate or scale the collider of the character. That will allow the raycast to pass above the character without it hitting the collider. If the character model is childed to the character controller (which i'm asuming it is...) then you might have to compensate for the rotation/scaling by doing the opposite to the character model itself.
Your answer
Follow this Question
Related Questions
Character Flying around uncontrollably 2 Answers
Prioritizing Player Animations 0 Answers
Click on an object and then edit the speed of my player? 1 Answer
Character controllers against each other 0 Answers
Scripting help 1 Answer