This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes
extends KinematicBody2D

var velocity = Vector2()
const SPEED = 30
const GRAVITY = 7
const FLOOR = Vector2(0, -1)
const JUMP_POWER = -150

var onground = false
var gun
activated = false

func physicsprocess(delta):

if Input.is_action_pressed("release"):
    if gun_activated == false:
        gun_activated = true
        $AnimatedSprite.play("re")
elif Input.is_action_pressed("unrelease"):
    if gun_activated == true:
        gun_activated = false

if Input.is_action_pressed("ui_right"):
    velocity.x = SPEED
    $AnimatedSprite.play("Run")
    $AnimatedSprite.flip_h = false
elif Input.is_action_pressed("ui_left"):
    velocity.x = -SPEED
    $AnimatedSprite.play("Run")
    $AnimatedSprite.flip_h = true
else:
    velocity.x = 0
    if on_ground == true:
        $AnimatedSprite.play("idle")

if Input.is_action_pressed("ui_up") || Input.is_action_pressed("Jump"):
    if on_ground == true:
        velocity.y = JUMP_POWER
        on_ground = false

velocity.y += GRAVITY

if is_on_floor():
    on_ground = true
else:
    on_ground = false
    if velocity.y < 0:
        $AnimatedSprite.play("Jump")
    else:
        $AnimatedSprite.play("Fall")

velocity = move_and_slide(velocity, FLOOR)
Godot version 3.4.2 win64
in Engine by (14 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 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.