Help with complex pathfinding for a shooter

Maybe it’s because you’re attempting to use a range with a negative number and a positive number.

If this returned a negative number, it would go down on the y-axis leading it to be under the baseplate. It wouldn’t even intersect the baseplate.

Do you need it to be a negative number? Or are you just trying to get a range in between? If you’re not, you can simple use math.abs (get the absolute value of the number)

Trying to randomize the pathfinding. then making it so if they spot someone then they get cover.

1 Like

My bad, I didn’t realize that the y spot was 0. You’re right

AHA issue:

-- its making it go in a really wierd position
local cast = Raycast(RayPos + Vector3.new(0,50,0),RayPos +Vector3.new(0,-50,0),{})
-- this is what it should have been
local cast = Raycast(RayPos + Vector3.new(0,50,0),Vector3.new(0,-50,0),{})
1 Like

Is that all that’s wrong? Mark ya post as the solution

That wasn’t what I was trying to accomplish. I wanted to make a way for this guy to find cover.

Hm well from the way I’ve interpreted it, I’d probably just check if the enemy is in the line of sight of a nearby player (you’d either retrieve that from a raycast or using a Spatial Query or manually checking the distance of each player)

If they are, then find a nearby object.

If the guy can crouch, basically do the equation to get the height (in Vector3 form) and see if any nearby objects is less than or equal to that value (you can use math.clamp for this)

Oh, I know that part. but what would be the most effective way to find an object?

Hm maybe raycasting I feel but in terms of performance, prolly not

That’ll be up to you I guess

Also new problem.


This guy thinks he can walk up walls. (he’s trying to Path find up the hill.)

With what you just said do you think I would have to put a point behind all hidable objects? then he would see which one is closest, provides best cover?

Npc

1 Like

You could however store all the objects that they can hide behind in a Folder

You could then iterate thru that folder and compare positions with the guy (is it a NPC or a player?)

Get the closest one and move behind it

Maybe you could come up with a way to get the longest side of the part and add something depending on what you get from that. Is that even possible? I’m not sure

Or you could just get the LookVector or the part and determine what to do from there.

Yes, I agree with that. I was wondering if there is a more effective way of doing it.

Also why doesn’t he jump over the ledge? He has can jump to true.

I’m not really sure. Try scouring some posts ig

You need to manually handle that. Basically add an if statement and check if Path.Action is equal to Enum.PathWaypointAction.Jump

From there you just manually set Humanoid.Jump to true

Here’s a huge tutorial on all of this

By the way I’m not sure why AgentCanJump doesn’t automatically perform a jump but that’s just how it is :man_shrugging:

But I rather have him walk up the stairs. He just ignores them and tries to jump up them. also path.action isn’t a thing.

1 Like

alright well I’m going To take a break. its late and I’m tired. I’ll come back tomorrow and keep working on it.

1 Like

I was just saying Path.Action like a placeholder, not something that corrolates with your actual variables

It should be for your code at least waypoint[i].Action

putting this as the solution to close the page

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.