- Home /
Player Teleporting on top of Enemy
Hi guys, I have recently experienced an issue where my player teleports on the upper side of the Enemy whenever it gets too close. I have no idea why it is occurring though. Regarding the setup: My player has a Character controller and a rigidbody (kinematic) components; the enemy has a Navmesh, a mesh collider and a rigidbody (kinematic) components. I worked on fixing it by turning the mesh collider into convex and turning 'is kinematic' off. That seems to work but I need to keep the mesh collider without it being convex, since my enemy is a donut and you have to be able to shoot through its hole. Some forums suggest that changing the height of the Navmesh Agent may be able to fix it, but it doesn't seem to be the case. It doesn't work changing the Character Controller slope limits either. I tried reducing the slope limit and the step offset to 0 but it didn't work. I would really appreciate some help. (this video shows the issue: https://youtu.be/pgNehwey_tI)
Answer by GeroNL · Feb 23, 2021 at 04:42 AM
Try to make like this in the enemy object on set position:
float rangeToAttack = 2f;
.......
if(Vector3.Distance(Player.transform.position, Enemy.transform.position)>rangeToAttack)
{
// set posisition
}
Hope it help.
Your answer
![](https://koobas.hobune.stream/wayback/20220613025640im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
OnMouseDown not firing if character isn't touching ground 0 Answers
Rigidbody slowly falling through mesh collider 0 Answers
Moving Trigger not detecting stationary MeshCollider 0 Answers
Fast moving object not detect collision 3 Answers
Non-coding question. How would I achieve this effect? 1 Answer