#Enemies which rotate towards player position.

1 messages · Page 1 of 1 (latest)

shrewd patio
#

I've been working on two different enemies for my game. Both of them need to be able to track the player's position and rotate to face them.

I initially tried using an IK control in LookAt mode, but jumping over the enemies causes them to flip upside down and fly all over the place. Ideally, I'd like to use IK controls while locking the movement in the Y Axis, though I don't know how to do that.

I also tried using CFrames, however I want to avoid this where possible for performance reasons, as well as the fact that it causes other issues elsewhere.

Any suggestions would be really helpful. Thanks.

vague wedge
#

atan2

shrewd patio
#

thanks. I'll see what i can do

rocky ridge
shrewd patio
#

I don't think I can do that. This is one I have to write myself. Can you describe the solution instead?

rocky ridge
#

Not until I can see the code

shrewd patio
#

at the moment it's just a while loop that constantly updates the CFrame of the HumanoidRootPart, which is obviously very inneficient

soft cove
#

if it's just a visual effect, you should put this on the client

shrewd patio
#

I see.

languid wagonBOT
#

studio** You are now Level 1! **studio

shrewd patio
#

The problem is that the enemies also have to be able to interact with players to some extent (e.g shoot at them, punch them .etc)

soft cove
#

oh yeah

shrewd patio
#

how would you still make it compatible with a system like that?

soft cove
#

as long as a player is close enough and it is able to attack, it should just aim attacks/hitboxes towards the player

#

that is relating more to your combat system rather than where the enemies face

shrewd patio
#

thanks for the suggestion

soft cove
#

no problem

#

just try to think of it like

#

I separate (mentally) the things an enemy or player or whatever you are making, should do in my head

#

I separate them based on if it is necessary for the thing to function, or if it's just a visual

#

for example, an enemy does not need to be facing towards a player to attack them, since you can program their behavior however you want

shrewd patio
#

yeah

soft cove
#

but if you would like them to face them visually, you can do that easily

soft cove
#

the enemy does not need a punch animation to punch or deal damage

#

however you obviously want that because it looks good

#

this is called polish basically

#

you can have a fully functioning game with no polish

shrewd patio
#

Yeah. I just don't think I ever considered that placing it locally would work

#

but thank you very much for the suggestions. I'll make sure to implement them

soft cove
#

yeah no problem

#

also, I read you were concerned about performance

#

as you should

#

but you can be much more lenient with performance on the client

shrewd patio
soft cove
#

yeah

soft cove
#

thats good

#

thats why visual stuff is best on the client side

shrewd patio
#

mhm

soft cove
#

you dont really need to worry about updating where something looks for everyone necessarily

#

since the game functions just fine without it

#

but yeah let me know if you have any questions