Scripts / rotate entity

Author
Message
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 10th Nov 2017 13:38
hi all.
i know that with : RotateY(e,v) i can rotate a entity constantly like: RotateY(e,10), what i need to know is how do i tel it just to rotate 180 deg or 90deg , if so how do i control it clockwise or anti clock wise

Thanks for any help.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 4GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Nov 2017 14:17 Edited at: 10th Nov 2017 14:20
assuming i remember correctly the rotation value is based on the frame rate so telling something to rotate by 60 will rotate 1 degree if your game is running at 60fps (0.5 if running at 30fps, 2degrees if running at 120fps etc).

so from this logic we know that we can rotate something a set amount by using a variable like so



but this will only work if the fps stays at exactly 60 and will take 90 seconds.
so you can improve the speed by making it rotate to the desired value instantly like so



now you'll likely want to improve this more by making sure your FPS is correct as it's very unlikely to be a flat 60fps at all times.



for rotating in anticlockwise you simply give a negative value as the amount to rotate by
RotateY(e,(fps*target_angle)*-1)

p.s. you will need to turn collision off to rotate correctly and also make sure any variables are defined outside of the main loop first to ensure they start at 0 etc.

an easier and more accurate method is to simply use the SetRotation command but this rotates around the global axis and not the object's local axis (so only fine if you haven't rotated the object away from those - i.e. up for the object is up for the game world).

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
PCS
8
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 10th Nov 2017 15:49 Edited at: 10th Nov 2017 15:49
Smallg, as always, you are a star. thanks a lot.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 4GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11

Login to post a reply

Server time is: 2024-12-23 00:39:15
Your offset time is: 2024-12-23 00:39:15