How can I get a ball or any object to rotate constantly?
10 comments
-
Gindipple Add some angular velocity to it
RigidBody.SetAngularVelocity(new Vector(0.0f, 0.0f, 1.0f, 0.0f));
-
djgeenen Is there anywhere I could see a simple, working example script that would include "RigidBody.SetAngularVelocity(new Vector(0.0f, 0.0f, 1.0f, 0.0f));"?
-
Gindipple Depends on several other factors, is it to be on the ground?
Did you upload a physics shape with it?
If it's to rotate in the air you'll also need to counter gravity, IE set the linear velocity upwards.
Also consider zeroing out that and the mass
Still learning things, I only just go an object to sit still for me lol
-
djgeenen Thanks again for your reply. It would be a ball spinning in the air. But it will be a fair amount of time before I figure out the C# scripting. I am brand new to it and the examples with the documentation are full of stuff I wouldn't need. Not knowing C#, I don't no what is are basic necessities for a valid script.
-
Gindipple Well there's going to be 2 things here, the general knowledge of C# and some general knowledge of physics
I have both and STILL struggling :)
The hard part is not knowing what's going on inside the box.
Like if mass is set to 0 can a collision still be detected?
Maybe the engine only reports back a collision if there is enough of an impulse, which may dictate the need for the hit object to have some mass.
FYI wade did put a free rotation script up if you simply want something to rotate up in the air.
-
djgeenen Where could I find the free rotation script? Nothing is going to collide with my object. I need to stay very super simple. I just want a little activity in my scene.
-
Gindipple https://store.sansar.com/search?q=script
Keep in mind there's no way to know right now if a script works after the library changed.
But I did test that one script and it worked after the change.
I also just removed my older script that no longer worked.
It will for now be up to the creators to remove broken scripts.
-
djgeenen Thanks for directing me to the script. I didn't know how to locate the store. I haven't been able to get it the rotation script to work yet and there doesn't seem to be anyway to see the coding that makes up the script.
-
wade665 Make sure the object is dynamic. Go to the property panel of the object then toggle "IsDynamic"
-
djgeenen Thanks for your input. I've got my objects rotating now. Thanks for writing the script and making it freely available.