+1 vote

I am currently having a problem with the main bit of my code. Instead of jumping and moving as it should, the character sprite just floats into the air out of nowhere when the game starts. I have tried to fix this by changing isactionpressed to isactionjust_pressed but it has seems to have not work.
thanks again for any help on this issue!

    extends KinematicBody

var MOVESPEED = 12
const JUMP
FORCE = 30
const GRAVITY = 0.98

const HLOOKSENS = 1.0
const VLOOKSENS = 1.0

onready var _cam = $Cambase
onready var anim = $Graphics/AnimationPlayer

var y_velo = 10

var velocity = 10
var onground = true
var has
doublejumped = false
var just
jumped = false

func ready():

func input(event):
if event is InputEventMouseMotion:
degrees.x -= event.relative.y * VLOOKSENS
cam.rotationdegrees.x = clamp(cam.rotationdegrees.x, -90, 90)
rotationdegrees.y -= event.relative.x * HLOOK_SENS

func physicsprocess(delta):
var movevec = Vector3()
if Input.is
movevec.z -= 1
if Input.is
movevec.z += 1
if Input.is
movevec.x += 1
if Input.is
move_vec.x -= 1

move_vec = move_vec.normalized()
move_vec = move_vec.rotated(Vector3(0, 1, 0), rotation.y)
move_vec *= MOVE_SPEED
move_vec.y = y_velo
move_and_slide(move_vec, Vector3(0, 1, 0))

func playanim(name):
if anim.current
animation == name:

var grounded = is_on_floor()
var y_velo = GRAVITY
var just_jumped = false
if grounded and Input.is_action_just_pressed("jump"):
    just_jumped = true
    y_velo = JUMP_FORCE
if Input.is_action_just_pressed("jump"):
    if just_jumped == true and has_double_jumped == false:
        has_double_jumped = true
        y_velo = JUMP_FORCE

if grounded and y_velo <= 0:
    y_velo = -0.1
if y_velo < -MAX_FALL_SPEED:
    y_velo = -MAX_FALL_SPEED
Godot version v3.2.3
in Engine by (16 points)

1 Answer

0 votes

I think you forgot to call playanim in your script.

by (254 points)
edited by
its still doing it
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 Frequently asked questions and 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 [email protected] with your username.