Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Demogo |
I am trying to create a system in which you can build 32x32 sized conveyors to create a conveyor belt system. So far I have the building and instancing created, but the problem I am running into is that with how the conveyor belts interact with objects that touch them.
I am using a KinematicBody2D
for the item being placed on the conveyor belt and an Area2D
for the conveyor belt itself.
The solutions I have tried so far have not worked properly, like trying to set the velocity of the item when it enters and leaves a conveyor belt.
Conveyor Belt:
extends Area2D
func _on_StraightConveyor_body_entered(body):
if !body.velocity == null:
body.velocity.x = 100
print("just touched")
func _on_StraightConveyor_body_exited(body):
if !body.velocity == null:
body.velocity.x = 0
print('just left')
Item:
extends KinematicBody2D
var velocity = Vector2()
func _physics_process(delta):
velocity = move_and_slide(velocity, Vector2())
With this solution, when the item moves along one conveyor belt, everything works as it should. But, if I add two or more conveyor belts in a chain, the item moves off the first conveyor belt, but then stops when it reaches the second.
Does anyone know a different solution I could use to achieve the goal of being able to move an item along multiple conveyor belts without these stops?