Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

gdscript 2d movement

extends KinematicBody2D

export (int) var speed = 200

var velocity = Vector2()

func get_input():
    velocity = Vector2()
    if Input.is_action_pressed("ui_right"):
        velocity.x += 1
    if Input.is_action_pressed("ui_left"):
        velocity.x -= 1
    if Input.is_action_pressed("ui_down"):
        velocity.y += 1
    if Input.is_action_pressed("ui_up"):
        velocity.y -= 1
    velocity = velocity.normalized() * speed

func _physics_process(delta):
    get_input()
    velocity = move_and_slide(velocity)
Comment

PREVIOUS NEXT
Code Example
Python :: bs4 find element by id 
Python :: python how to obfuscate code 
Python :: selenium send keys python 
Python :: python die 
Python :: python locks 
Python :: f string python not working in linux 
Python :: sheebang python 
Python :: write a python program to find gcd of two numbers 
Python :: what is the tracing output of the code below x=10 y=50 if(x**2 100 and y <100): print(x,y) 
Python :: how to install django in virtual environment in ubuntu 
Python :: Date difference in minutes in Python 
Python :: merge multiple csv files into one dataframe python 
Python :: how to get started with python 
Python :: python one line return 
Python :: procfile heroku django 
Python :: python filter list of int and strings 
Python :: python read text file into a list 
Python :: django check if user is staff in template 
Python :: zermelo api 
Python :: equivalent of setInterval python 
Python :: generate valid sudoku board python 
Python :: matplotlib title chopped off 
Python :: plotly not showing in colab 
Python :: get time between things python 
Python :: how to pipe using sybprosses run python 
Python :: revesing case python 
Python :: filter function using lambda in python 
Python :: python strip multiple characters 
Python :: not importing local folder python 
Python :: how to reverse a list in python using for loop 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =