[SCRIPT] [SOLVED] Rotate entity fixed amount of degrees - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] [SOLVED] Rotate entity fixed amount of degrees (/thread-24936.html) Pages:
1
2
|
[SOLVED] Rotate entity fixed amount of degrees - Reminiscity - 03-28-2014 Hi! RotatePropToSpeed(string& asName, float afAcc, float afGoalSpeed, float afAxisX, float afAxisY, float afAxisZ, bool abResetSpeed, string& asOffsetArea); Can I get this to rotate my entity a fixed amount of degrees and then stop? I need the entity to rotate exactly 120 degrees whenever the player clicks on an area. Thanks in advance for any help RE: Rotate entity fixed amount of degrees - PutraenusAlivius - 03-28-2014 Put a float in either afAxisX or afAxisZ, depending on the location. RE: Rotate entity fixed amount of degrees - Mudbill - 03-28-2014 This script uses the X, Y and Z axises to rotate the object. If you decide to use the X axis, the object will rotate around the red line in the level editor. Z will use the blue and Y uses the green. Using Y will have it spin around itself in a vertical fashion from the center, or from its offset area. RE: Rotate entity fixed amount of degrees - Reminiscity - 03-28-2014 I only manage to make the prop rotate constantly. I want it to rotate 120 degrees then stop. I guess I could calculate how long it takes for the prop to rotate 120 degrees then stop it but that doesn't seem very robust cuz if the calculations are off just a tiny bit then after several clicks by the player it will no longer work. RE: Rotate entity fixed amount of degrees - PutraenusAlivius - 03-28-2014 (03-28-2014, 03:04 PM)Reminiscity Wrote: I only manage to make the prop rotate constantly. I want it to rotate 120 degrees then stop. I guess I could calculate how long it takes for the prop to rotate 120 degrees then stop it but that doesn't seem very robust cuz if the calculations are off just a tiny bit then after several clicks by the player it will no longer work. What you could do is just make it rotate and then add a timer that allows it to stop (and un-interactable if you want). RE: Rotate entity fixed amount of degrees - Reminiscity - 03-28-2014 (03-28-2014, 04:26 PM)SomethingRidiculous Wrote:(03-28-2014, 03:04 PM)Reminiscity Wrote: I only manage to make the prop rotate constantly. I want it to rotate 120 degrees then stop. I guess I could calculate how long it takes for the prop to rotate 120 degrees then stop it but that doesn't seem very robust cuz if the calculations are off just a tiny bit then after several clicks by the player it will no longer work. Yeah that was what I was thinking but it feels pretty weak. If the prop rotates even 121 degrees during the timers delay it will make my puzzle broken if the player decides to spam click 30 times for reasons unknown xD Maybe I should have explained why it must be exactly 120 degrees. I have a wheel with 3 images attached to it with even distances from eachother. When the player clicks an area the wheel rotates to show a different image in front of the player. It has to spin 1/3 of a full spin (120 degrees) each time the player clicks. RE: Rotate entity fixed amount of degrees - Mudbill - 03-28-2014 Why don't you use SetMoveObjectState and make the entities into MoveObjects? That's what I do, and it works pretty well because you can define in the entity how much "state 1" is. You can input exactly 120 degrees if you'd like. Default is 90 for angular. RE: Rotate entity fixed amount of degrees - Reminiscity - 03-28-2014 (03-28-2014, 05:52 PM)Mudbill Wrote: Why don't you use SetMoveObjectState and make the entities into MoveObjects? That's what I do, and it works pretty well because you can define in the entity how much "state 1" is. You can input exactly 120 degrees if you'd like. Default is 90 for angular. Thank you that seems to be the right way to go about this. I changed the open amount to 1.33 to get 120 as state 1. When clicked the wheel spins 120 degrees and then stops. However, when clicked a third time nothing happens. I've tried this (script below) and variations there of but nothing happens. SetMoveObjectState("area_symbol_1_wheel", GetLocalVarInt("symbol_1_spins") + 1); AddLocalVarInt("symbol_1_spins", 1); Edit It seems like open amount is the maximum number of degrees it can rotate. Which means that I want it to be set to 4 to get a full spin(360 degrees) since 1 is 90 degrees. Then in script do something like this SetMoveObjectState("area_symbol_1_wheel", GetLocalVarInt("symbol_1_spins") * 0.33); AddLocalVarInt("symbol_1_spins", 1); BUT the maximum amount you can input in the open amount field is 2 which is 180 degrees. You can write 4 if you want but it seems like it still will be read as 2. So... wtf xD I feel and wish that I'm making things too complicated or that I'm just too tired atm cuz something like this should be easy imo... rotate prop x amount of degrees along X axis. Fml RE: Rotate entity fixed amount of degrees - Mudbill - 03-28-2014 Oh, right. I remember now. Yeah there are troubles using it above the max rotation. I guess that makes this not work. I think using that script would be the only way then. I once made an entity that was continuously rotating in a loop. I used the script PHP Code: RotatePropToSpeed("ts_vinyl_1", 5.0f, 5.0f, 0.0f, -360.0f, 0.0f, false, ""); Spoiler below!
It says on the page that the entity must be a StaticObject prop, but this worked fine for me using a MoveObject with the script. Perhaps it gives you some ideas as to what to try out. I'm sure this is possible. Perhaps putting 120 in the places I put 360, and not have AutoMove on. RE: Rotate entity fixed amount of degrees - Reminiscity - 03-28-2014 (03-28-2014, 08:10 PM)Mudbill Wrote: Oh, right. I remember now. Yeah there are troubles using it above the max rotation. I guess that makes this not work. I think using that script would be the only way then. This is was I tried just before posting the thread RotatePropToSpeed("area_symbol_1_wheel", 1, 1, 120, 0, 0, true, ""); That contantly spins the prop which is not what I want but it seems like the only way. So it's back to the timer method, that is, letting the prop spin constantly and then stop it with a timer with like 10 decimals xD Obviously my timer will not have 10 decimals since I have to mostly rely on my eyes but maybe 3 decimals. If I knew what the speed of the rotation is measured in then I could calculate how long it has to be spinning. Right now the speed is 1... but what does that mean? 1 degree a second? No, that much I'm sure of derp xD But that would be the key to calculating an exact delay for the timer I guess. |