0 votes

I just don't understand why this isn't working....

onready var t1 = $test1 #just a meshinstance

func _process(delta):
    t1.rotate(Vector3(0,0,-10), .1)

The mesh is gone and this error is polluting the debugger: Condition ' !paxis.isnormalized() ' is true.

asked Dec 27, 2019 in Projects by Dumuz (236 points)

1 Answer

+1 vote
Best answer

Instead of t1.rotate(Vector3(0,0,-10), .1), write t1.rotate(Vector3(0,0,-10).normalized(), .1)

answered Dec 27, 2019 by johnygames (1,576 points)
selected Dec 28, 2019 by Dumuz

I then get the error:

Parser Error: invalid index 'normalized' in constant expression.

Oops! My bad, it should have been:

t1.rotate(Vector3(0,0,-10).normalized(), .1)

Forgot to add the parentheses at the end of the normalized method.

Ah, there we go.

Unfortunately that is not what I thought it was. But you answered my question. So, thank you very much!
Do you perhaps know to how to make a 3D object rotate around another object it is not a child or parent of?

I am not sure how to do that, but let's say you have a planet and you want a satelite to revolve around it. A quick and dirty way would be this:

1) Create a Position3D node and place it at the center of the planet.

2) Have the Position3D node update its rotation any way you like.

3) Make the Position3D node a parent to the satelite.

4) Place the satelite as far or close as necessary to the planet.

5) Voila! Your satelite revolves around the Position3D node, which in turn rotates the way you like. That way you also avoid making the planet a direct parent to the satelite.

For a more advanced way, read up on this:
https://godotengine.org/qa/34248/rotate-around-a-fixed-point-in-3d-space

I am not sure, but I think this atan method looks promising. You could also google "Godot orbit", since what you want is technically orbital movement. I hope this helps.

Oh man, you think I would have thought of that process with my animation background. Lol. Thanks man, you're a real help!

You're welcome!

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.