Hi there, I’m currently developing a combat sysetm and i’m now onto the ai… When the ai attack currently they warp towards the players actor location. But i want to know how to make it so the ai aren’t so close to the player as there hands are cliping through. Any help would be appriciated.
if you have a destination at the player location you can add to its x and y position some sort of buffer based on either directly adding to them or with some trig. either way you should be able to set a “buffer zone” by just adding in another vector to the teleport location
Yes! However my main concern is how do i know if i should add it to x or y?
play around to see what works.
Sometimes it would need to be x however there will be times where it needs to be y. Since it depends on the direction the enemy id attacking and the player is facing no?
yup. so you’ll want to check the distance vector and make sure the spawn point is x distance away, if not you can say move to a projected vector in the xy plane from the camera’s direction, but x distance away
so that’ll require a bit of trig to do but it is feasible since the player’s camera location is easilly accesed.
Get z rotation of the camera + define a distance float of your choice
add to the teleport location on x: cos(lookatangle)*distance float
add to the teleport location on y: sin(lookatangle)*distance float
reminder to make sure you have the right units of angle (radians vs degrees)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.