Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | edimemune | |
Old Version | Published before Godot 3 was released. |
I am working on a game with a ball and I created the basic movement, but when I move on ground surface, the ball moves very slowly.
An screenshot from the project:
https://drive.google.com/open?id=0BxW0b-YjQRdXUmI0MVpNS29UVDQ
And the code attached to the ball:
extends KinematicBody2D
export var viteza = 30
var animNod
var jumped = false
var falling = false
var y
func _ready():
animNod = get_node("AnimatedSprite")
set_fixed_process(true)
func _fixed_process(delta):
#MISCARE
delta *= 10
var misc = Vector2(0,1)
if(jumped):
if(get_pos()[1] > y and not falling):
print("Da")
misc[1] = -1
elif(get_pos()[1] <= y):
falling = true
if(Input.is_key_pressed(KEY_D) or Input.is_key_pressed(KEY_RIGHT)):
misc[0] = 1
if(Input.is_key_pressed(KEY_A) or Input.is_key_pressed(KEY_LEFT)):
misc[0] = -1
misc = misc * (delta * viteza)
self.move(misc)
#ANIMATIE
var newAnim = "idle"
if(Input.is_key_pressed(KEY_D) or Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_A) or Input.is_key_pressed(KEY_LEFT)):
newAnim = "mers"
#Jump --->
if((Input.is_key_pressed(KEY_SPACE) or Input.is_key_pressed(KEY_W)) and not jumped):
jumped = true
var jH = 50
y = get_pos()[1] - jH
print(jumped)
#<--- Jump
animNod.play(newAnim)
var corp = get_collider()
if corp != null:
if corp.is_in_group("sol") and falling:
jumped = false
falling = false
What is wrong?