How to make 'collisions' with tough and drag with godot
I create a node using a kinematicbody2D, and then apply sprite, collisionShape and touchScreenButtonn to it (with area above the kinematicbody). I create another collision node at the edge of the screen. I create the main node and join all the nodes.
The problem IS that when the kinematicbody must collide, it does so but very weak and goes through the collision. https://www.youtube.com/watch?v=UumM2Xz7_zk
extends KinematicBody2D
var velocidad = Vector2()
var movimiento = Vector2()
var touchACT = false
var newdeltax
var deltax
func _on_TouchScreenButton_pressed():
touchACT = true
func _on_TouchScreenButton_released():
touchACT = false
func _input(event):
if touchACT == true:
if event is InputEventScreenTouch and event.is_pressed():
velocidad = event.get_position()
deltax = velocidad.x - position.x
elif event is InputEventScreenDrag:
velocidad = event.get_position()
newdeltax = velocidad.x - deltax
set_position(Vector2(newdeltax,0))
func _physics_process(delta):
move_and_collide(movimiento)
from Recent Questions - Stack Overflow https://ift.tt/352OVH1
https://ift.tt/eA8V8J
Comments
Post a Comment