I am trying to make a game in whihc the player controls a character, and pushes enemies off the road; it is a 2d game. For some reason, the enemies start moving like CRAZY! I think it's because the forces from the player are still applied onto them. I don't know thow to fix this!
Here is the code for the enemies is this helps:
extends RigidBody2D
const SPEED = 100
func _ready():
teleport()
func teleport():
self.position.x = 0
self.position.y = randi()%100 +242
self.setlinearvelocity(Vector2.RIGHT*SPEED)
func physicsprocess(delta):
self.zindex = (position.y /10 ) as int
if (position.y > 342) or (position.y < 242) or (position.x < 0) or (position.x > 751):
teleport()
func onredEnemybodyentered(body):
if body.name == "Cake":
teleport()