+1 vote

I am switching from Unity to Godot and wanted to restart one of my Unity projects in Godot. This requires a "ping-pong" of the rotation value, so my player is rotating back and forth. In Unity I could use the Mathf.pingpong function. Is there any way to use something like this in Godot?

in Engine by (13 points)

2 Answers

0 votes

Check out this: Unity Forums | what exactly does Time.time do in Mathf.pingpong

You can use the information there to implement a utility method that does the same in Godot.

by (64 points)
0 votes

This will pingpong a value between zero and one, scaled by amplitude. The sine function returns a value between -1.0 and 1.0 which is then converted to the range 0.0 to 1.0

value = (sin(time) + 1.0) * 0.5 * amplitude
by (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.