Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Sumerechny |
Hello.
So I followed this tutorial https://www.youtube.com/watch?v=9CKH5fanubM and near the end it explains how to attach collision shapes to objects. I think I did it exactly like in the video, but no matter what I do my character always falls through the floor. This is how my project looks right now problem hosted at ImgBB — ImgBB
Did something change in 3.0? Because I remember it working when I was playing around with Godot 2.1 some time ago.
How are you moving the player? Can you share the player script?
kidscancode | 2018-02-11 22:51
This is the player script
extends KinematicBody2D
var input_direction = 0
var direction = 0
var speed_x = 0
var speed_y = 0
var velocity = Vector2()
const MAX_SPEED = 600
const ACCELERATION = 1000
const DECELERATION = 2000
const JUMP_FORCE = 800
const GRAVITY = 2000
func _ready():
pass
func _input(event):
if event.is_action_pressed("ui_spacebar"):
speed_y = -JUMP_FORCE
func _process(delta):
if input_direction:
direction = input_direction
if Input.is_action_pressed("ui_left") and Input.is_action_pressed("ui_right"):
input_direction = 0
elif Input.is_action_pressed("ui_left"):
input_direction = -1
elif Input.is_action_pressed("ui_right"):
input_direction = 1
else:
input_direction = 0
if input_direction == - direction:
speed_x /= 3
if input_direction:
speed_x += ACCELERATION * delta
else:
speed_x -= DECELERATION * delta
speed_x = clamp(speed_x, 0, MAX_SPEED)
speed_y += GRAVITY * delta
velocity.x = speed_x * delta * direction
velocity.y = speed_y * delta
move_local_x(velocity.x)
move_local_y(velocity.y)
pass
Sumerechny | 2018-02-11 22:58