Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Want to learn making |
I am a newbie and I want to know how I can make my Kinematic body move to right left up and down .
My code is :
extends KinematicBody2D
class_name Actor
var speed : int = 200
var jumpForce : int = 600
var gravity : int = 800
var vel : Vector2 = Vector2 ()
onready var sprite : Sprite = get_node(“Sprite”)
func _physics_process(_delta):
vel.x=0
#movement inputs
if Input.is_action_pressed(“move_left”):
vel.x-=speed
if Input.is_action_pressed(“move_right”):
vel.x+=speed
#apllying the velocity
vel = move_and_slide(vel , Vector2.UP)