[SOLVED] Rotating Obstacles

I am developing this game called trigo run, i need help on obstacles that can rotate freely without user input like a saw blade
Screenshot 2022-03-16 15.36.09
, it would rotate forever and at a certain speed.

i do not need the moving part right now i just need the rotating part

Hi @Kevin_Herod,

Provided the blades object is not a static/dynamic rigidbody (kinematic works), you can use the a single method to do that in your script’s update method:

MyScript.prototype.update = function(dt){

   const rotationSpeed = 3;
   this.entity.rotateLocal(0, 0, rotationSpeed  * dt);
};

I selected to rotate the entity on the Z axis, if you the pivot point of your object rests on a different axis, change that accordingly.

how do i apply this to the entity? though

Hi @Kevin_Herod! You can apply this to the entity by adding the script with the code above to the script component of the entity.

so i turn this into a new script and copy this code and add this into entity

You can copy and past the two rules from the update function above to the update function of your new script.

do i delete the code that is already presented when i create a new script or keep it

You keep it.

k thanks, but just for further remedies can you give me a project example?

please i be given a project example

Unfortunately, there is no example for this. Does it already work for you?

well when i add it as a script it doesnt add any like editor things for the object

like shouldn’t you see like the editor thingy like adjuster thing like this?

like where you can do like that random editing stuff without going into the code

an i have tested it and it doesnt rotate

the thing im standing on in-game should be rotating but it wont move an inch

With the current code, no. You need to make adjustments in the script itself.

it doesnt work tho it wont rotate in honestly REALLY need a project to base off of because the code won’t work

I’m not sure which object you mean. Make sure you rotate it on the right axis, as @Leonidas already mentioned. Also if you move or rotate an entity it can’t have a static rigidbody. I suggest to make it kinematic in this case.

mine has kinematic

i made sure i made it kinematic, and i want to rotate the object my character (the cyan cube) is standing on