Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | mister_why | |
Old Version | Published before Godot 3 was released. |
Hello !
I’m making a game (no kidding), and the object (kinematicsbody2D) isn’t colliding with the wall (Staticbody2D).
The objects has a collision shape, and it still a mystery to me why it doesn’t work.
A beer to the person who can resolved my problem ^^
extends KinematicBody2D
var SPEED = 1000
var MAX_SPEED = 3000
var vel = Vector2()
var JUMP_FORCE = 1500
func _ready():
#set_process(true)
set_fixed_process(true)
func _fixed_process(delta):
if Input.is_key_pressed(KEY_SPACE):
vel.y = -JUMP_FORCE
elif Input.is_key_pressed(KEY_DOWN):
vel.y = SPEED
elif Input.is_key_pressed(KEY_RIGHT):
vel.x = SPEED
elif Input.is_key_pressed(KEY_LEFT):
vel.x = -JUMP_FORCE
else:
vel = Vector2(0, 0)
#set_pos(get_pos() + vel * delta+ Vector2(0,9.81))
set_pos(get_pos() + vel * delta)
Not enough info, you need to upload your project or at least post all the relevant scripts and your scene hierarchy.
raymoo | 2017-07-14 02:08
as the one above said, not enough information but by guessing, check that all the collision shape’s trigger option is set to false(not ticked) and that you are using move() and not set_pos() in order to move your character
rustyStriker | 2017-07-14 10:10
I’ve checked the code you posted and I don’t see anything related to collision. But there are some typos in it like, you used setfixedprocess()
instead of set_fixed_process()
and the function fixedprocess()
instead of _fixed_process()
. These are functions in Node class.
codevanya | 2017-07-14 16:43
Nope the set_fixed_process() etc are good, it’s the copy and paste who eat all of the “_” ^^
But, the collisions, are defined with the collision shape isn’t ? If I put 2 KinematicBody2D with sprites and collision shape, they collided isn’t ?
mister_why | 2017-07-14 17:21
@codevanya You just can’t see the underscores because the Q&A-site interprets them as markdown because the OP didn’t wrap his code in a code block (intend with four spaces).
timoschwarzer | 2017-07-14 20:11