Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do you make an advanced sword fighting AI? (Solved)

Asked by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

This is a one-sentence summary. Silly mods.

Solution: I'm going to try to make different parts that are in the correct position relative to the AI and the player, then move the AI to those points. I will then use CFrame to rotate it correctly.

Original post: I want to simulate mouselock or moonwalk (first person) in an AI. Basically if someone comes close enough the bot will walk side to side, jabbing forwards and backwards, while always facing its target.

Obviously, AutoRotateCharactermust be set to false, so the bot can move while still facing it's target.

Getting the target would be relatively simple code, but the part I'm not sure how to do is actually move the bot back and fourth, forward and backward, relative to the target. I can't just move it between two points on a map, because then the player could just go around the bot. I want the bot to remain facing the target. I'm not sure how to accomplish this.

This is not a request, because I'm not asking for code. I'm simply asking for ideas.

Any answers are appreciated, but please try to be as detailed as possible.

0
Since you seem to have the automatic facing handled, is it possible to just use WalkToPoint to move the guy around? You can get the relative Vector3 of the AI and the target's Torsos to find some mid-Points to WalkTo. If you're good at vector math, you could also use the AI's Torso's lookVector and shift him left and right perpendicular to it. adark 5487 — 10y
0
I do not know how do get the automatic facing. I would normally use CFrame.new(startPosition, lookAt), but it seems like CFrame is not normally used on NPCs. If this would be sufficient, great, but if not I do not know any other ways to rotate the character. And I know almost nothing about vector math, I'm still in Algebra I. Perci1 4988 — 10y
0
Look into getting perpendiclar 3D Vectors from a given unit vector, then. Rotating by setting the CFrame of the AI's torso should be sufficient, too. adark 5487 — 10y
0
I understand unit vectors (i think), but how would I get one perpendicular to (yourTorso.Position - AITorso.Position).unit so I can move the AI along that? On a side note, I don't understand how the question title isn't a one sentence summary. Perci1 4988 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

Make a script that will track how close the player is to the bot, put pathfinding onto it so it doesn't get stuck into a wall, now when it's found you need to make it follow the player until the distance has not been met.

I hope I helped.

0
That is a simple bot that charges a player, but I want to replicate mouselock style sword fighting. Perci1 4988 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Adding onto what CharcterKaiser said, you could always try to get the bot within a certain lunging distance of the player, and then it would attempt to lunge while pathfinding a route backwards, if the route isn't possible look for back left and back right, if that's not possible try to lunge jump over the player. I know this isn't a full answer that you are looking for but it may be a start.

Answer this question