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
7 years ago
Edited 7 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)

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

(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
7 years ago
Edited 7 years ago

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

wait(3)
game.Players.Player1.DevEnableMouseLock=false
local char = workspace.Player1
local dir = char.Torso.CFrame.lookVector
local heartbeat = game:GetService('RunService').Heartbeat

spawn(function()
    while heartbeat:wait() do
        local cf = char.Torso.CFrame
        char.Torso.CFrame=CFrame.new(cf.p,cf.p+dir*500)
    end
end)
while wait() do
    char.Humanoid:Move(dir*-1)
end
0
Damn you stole my answer. Meltdown81 309 — 7y
Ad

Answer this question