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

How would I make something walk backwards?

Asked by
3dsonicdx 163
8 years ago
Edited 8 years ago

Issue

I'm working on a mini fighter. Attacking knocks away the target a certain distance, but sometimes they end up ontop of each other. Movement is automatic(so the game controls both player and AI movement to allow people to focus on comboing(or button mashing if you will).

First idea was just to move the character by walking towards a location, but that isn't exactly ideal because it looks awkward in a fight(turning away from your opponent).

Ideal Solution

Have either player or AI move 'backwards' a certain distance(or magnitude) while facing the other character.

What I have

(Snippet from the code)

1local magnitude = (target.Position - torso.Position).magnitude
2if magnitude >= 7 then
3script.Parent.Humanoid:MoveTo(target.Position, target)
4elseif magnitude <= 4 then
5    -- proposed code
6    else
7script.Parent.Humanoid:MoveTo(torso.Position, torso)
8end

(TLDR - Moves until they reach a certain distance, otherwise moves if they're too close, and otherwise stands still.)

Is there any way to make a character walk 'backwards'?

1 answer

Log in to vote
2
Answered by
cabbler 1942 Moderation Voter
8 years ago
Edited 8 years ago

I don't know how much this will help you, but this a really rigid way to keep a character walking backwards.

01wait(3)
02game.Players.Player1.DevEnableMouseLock=false
03local char = workspace.Player1
04local dir = char.Torso.CFrame.lookVector
05local heartbeat = game:GetService('RunService').Heartbeat
06 
07spawn(function()
08    while heartbeat:wait() do
09        local cf = char.Torso.CFrame
10        char.Torso.CFrame=CFrame.new(cf.p,cf.p+dir*500)
11    end
12end)
13while wait() do
14    char.Humanoid:Move(dir*-1)
15end
0
Damn you stole my answer. Meltdown81 309 — 8y
Ad

Answer this question