Sunday, June 19, 2022
HomeGame Developmentunity - I'm in search of a versatile solution to rotate a...

unity – I’m in search of a versatile solution to rotate a gameobject round one other


I attempt to make an object rotate round one other object on mouse enter. With a view to obtain this I used this code:

remodel.RotateAround(objectToRotateAround.remodel.place, Vector3.again, Enter.GetAxisRaw("Horizontal") * Time.deltaTime * velocity);

I exploit GetAxisRaw as a result of the motion must be exact (the sport that I’m making requires a whole lot of response).

The issue is the defend motion would not really feel good. I would love to have the ability to add slightly little bit of friction to the motion.

An answer that may allow me to tweak sure points of the rotation can be ultimate. Any type of steering or documentation which may assist can be very well-received 😄.

PS: I additionally tried to work with Quaternions. This was the code that I’ve tried.

 Vector3 relativePos = objectToRotateAround.remodel.place - remodel.place;
 remodel.rotation = Quaternion.Slerp(remodel.rotation, Quaternion.LookRotation(relativePos,Vector3.ahead), Time.deltaTime);
 remodel.Translate(0, 0, Enter.GetAxisRaw("Horizontal") * Time.deltaTime * velocity);

There are just a few issues with this code.

The Quaternion.LookRotation rotates my object on all 3 axes as an alternative of the Y-axis.
I feel even when the thing rotates correctly, the Translate technique will make it transfer the identical because the earlier resolution.
Thanks in your time and a spotlight. I actually respect it.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments