Author Topic: claymore help (need help)  (Read 1823 times)

So i have a script for a claymore but its search radius is in a sphere, and i dont want that, i want it to be a flat search radius that also faces the direction the front of the claymore faces, so it doesnt explode when someone walks under it or behind or to the side or above it lol
 :cookie:

You could make a loop to use ray casts, or have a radius loop, but only detects if the person is in front of the claymore.

exactly how i want itf

When the claymore is placed why not tag the direction the player is facing onto the claymore object, then if someone is detected in the radius check to see if their position is in front of the claymore?

When the claymore is placed why not tag the direction the player is facing onto the claymore object, then if someone is detected in the radius check to see if their position is in front of the claymore?
i like it how would i do that? and would that get rid of the spherical search radius?

Keep the radius search, but add two additional checks before it explodes.
First, make sure the player is in front of the claymore. You can do this by seeing if the dot product of the forward vector of the claymore, and the direction to the player from the claymore, is more/less (not sure, experiment a little) than a certain threshold. The dot product should go from 0 to 1 depending on the angles (assuming both vectors have a length of one).
Second, send a raycast from the claymore to the target, to make sure no bricks are in the way. I recommend using getHackPosition of the target to get the center of the player object.

You can find out how to do both of these by searching the coding help board. For the first one, search for "can see", and use code for checking whether a player can see another object, and modify it for your own use.