This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+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 (294 points)
+1 vote

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 (24 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 Frequently asked questions and 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 [email protected] with your username.