0 votes

I'm working on a soon to hopefully be zombie survival game.. but I'm getting a weird glitch while trying to rotate the legs to face the direction of input (in a sum and total), so that the legs(sprite) seem like there facing towards the direction you're walking...

I have this for my movement so far..

var velocity = Vector2()
var rotationspeed = 180
var rot
dir = 0

func ready():
set
process(true)

func getinput():
rot_dir = 0
velocity = Vector2()
if Input.is
actionpressed('uiright'):
velocity.x += 1
rotation += -90
if Input.isactionpressed('uileft'):
velocity.x -= 1
rotation += 90
if Input.is
actionpressed('uidown'):
velocity.y += 1
if Input.isactionpressed('ui_up'):
velocity.y -= 1
velocity = velocity.normalized() * speed

func control(delta):
$Body.look
at(getglobalmouse_position())

func physicsprocess(delta):
getinput()
move
and_slide(velocity)

the code in bold-italics is me attempting to get rotation to the legs(sprite) movement.. but I see now that the glitch is probably my code attempting to rotate my whole kinematic-body and my body(sprite) is attempting to follow the mouse at the same time.. so I suppose my new question is..
How would I move the legs of my character separately to the body with key input?
(while keeping my body and legs in place of the whole kin-body)
(I'll figure that part out if I can manage to rotate sprite animation with key in put without it effecting my movement)

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.