Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

godot 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 :: pd.merge left join 
Python :: my django template doesnt want to load the static file 
Python :: sort by column dataframe pyspark 
Python :: convert categorical variable to numeric python 
Python :: python -m http 
Python :: python psycopg2 utf8 
Python :: choosing the correct lower and upper bounds in cv2 
Python :: bnbpay 
Python :: get package share vs FindPackageShare 
Python :: Can only use .str accessor with string values! 
Python :: datetime current year 
Python :: factors addition in pyhone 
Python :: python import stringio 
Python :: não nulo pandas 
Python :: how to reverse a number in python 
Python :: show image with ratio opencv python 
Python :: pickle dump 
Python :: dont filter= true in scrapy 
Python :: python list group by count 
Python :: pandas drop column by index range 
Python :: pyqt5 qtwebenginewidgets not found 
Python :: python sum of digits in a string 
Python :: numpy add axis 
Python :: start django project 
Python :: how to obtain the content of brackets 
Python :: add padding to 2d matrix p 
Python :: permutations python 
Python :: how to make nmap port scanner in python 
Python :: pandas column not in list 
Python :: opencv get contours 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =