About 'Resetting the Game'!

In this video (objectives)…

1 Freeze the ball and players when a goal is scored 2 Reset the ball and player positions after some time has passed

After watching (learning outcomes)…

Using Axis Lock to immobilise objects

(Unique Video Reference: 11_CK_GDT)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

Hi,

I have a question about resetting the balls physics after the pitch is reset after a goal. I have the issue that the balls velocity that it was traveling at when it went into the goal is still being applied after the ball and the players positions have been reset. it makes sense the physics engine would assume it is still moving but I would like to stop it.

Is there an easy answer for this? I have tried setting the linear velocity to Vector3(0,0,0) but that didn’t help. I am wondering if there is a way to clear the physics engine. I am sure freeing the ball and recreating it during each reset will work…or applying a reversing force… just wondering if there is something easier I am not aware of… or if I even missed something while watching the video?

Cheers!

I managed to resolve the problem by removing the ball from the scene, freeing it and creating a new ball scene instance.

Not sure if this is the best way? I would like to think there is a nicer way to reset a physics object state.

I ran into the exact same problem. I worked around it by adding the following code to the Game.gd file:

func _physics_process(delta):
	if not timer.is_stopped():
		ball.set_linear_velocity(Vector3(0,0,0))

Furthermore, I removed the axis_lock calls in the reset pitch and goal detection functions, as they are no longer needed with this. Setting the linear velocity outside of the physics_process function did not appear to work. Not quite certain whether this is working as intended for Godot or not to be fair.

Privacy & Terms