Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Flame_Games |
Hi, I followed a tutorial of make these two interact but, with this code:
extends KinematicBody2D
var Up = Vector2(0, -1)
var Motion = Vector2()
const Speed = 200
export (int, 0, 200)var push = 100
func _physics_process(delta):
Motion.y += 10
if Input.is_action_pressed(“ui_right”):
Motion.x = 200
elif Input.is_action_pressed(“ui_left”):
Motion.x = -200
else:
Motion.x = 0
move_and_slide(Motion, Up, false, 4, PI/4, false)
if is_on_floor():
if Input.is_action_just_pressed("ui_up"):
Motion.y = -400
for index in get_slide_count():
var collision = get_slide_collision(index)
if collision.collider.is_in_group("bodies"):
collision.collider.apply_central_impulse(-collision.normal * push)
But the Rigidbody 2D does not interact with my player! PLEASE HELP!
have you debugged to see if the code is actually entering the apply_central_impulse
instruction? Double check collision masks and layers, and if you can, provide a minimal example project reproducing the error, so we can test on our machines.
p7f | 2020-07-22 16:38