I am new to playCanvas and I am trying to rotate an object only if the mouse is clicked over the entity. I have tried using the rotate object with mouse. It is not useful as it rotates the object when you click anywhere on the screen. I tried to combine the ‘rotate object with mouse’ scripts with the ‘Entity picking’ example.
I am not able to combine them. Here is a link to my project: https://playcanvas.com/editor/scene/619311
Could you please help
Dear Mr. Vishesh,
To rotate the clicked entity, use entity.setRotation ().
You are currently using this.entity This is the entity to which you added the script.
var ent=this.app.systems.rigidbody.raycastFirst(camFrom, camTo);
ent.entity.rotateLocal(90, 0, 0);
Respectfully, Dr. Simon Hack
That is not what I desire. I might have not explained it clearly.
What I want is the object should only rotate around its own axis when I click over the object and move my mouse while the button is still pressed.