Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help [SOLVED] Rotate entity fixed amount of degrees
Reminiscity Offline
Member

Posts: 81
Threads: 16
Joined: Jan 2013
Reputation: 2
#1
[SOLVED] Rotate entity fixed amount of degrees

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 Smile

My mod Amadeus
(This post was last modified: 03-29-2014, 02:49 PM by Reminiscity.)
03-28-2014, 01:00 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Rotate entity fixed amount of degrees

Put a float in either afAxisX or afAxisZ, depending on the location.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-28-2014, 07:18 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: Rotate entity fixed amount of degrees

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.

(This post was last modified: 03-28-2014, 09:52 AM by Mudbill.)
03-28-2014, 09:50 AM
Find
Reminiscity Offline
Member

Posts: 81
Threads: 16
Joined: Jan 2013
Reputation: 2
#4
RE: Rotate entity fixed amount of degrees

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.

My mod Amadeus
03-28-2014, 03:04 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#5
RE: Rotate entity fixed amount of degrees

(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).

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-28-2014, 04:26 PM
Find
Reminiscity Offline
Member

Posts: 81
Threads: 16
Joined: Jan 2013
Reputation: 2
#6
RE: Rotate entity fixed amount of degrees

(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.

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).

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.

My mod Amadeus
(This post was last modified: 03-28-2014, 04:44 PM by Reminiscity.)
03-28-2014, 04:40 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: Rotate entity fixed amount of degrees

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.

03-28-2014, 05:52 PM
Find
Reminiscity Offline
Member

Posts: 81
Threads: 16
Joined: Jan 2013
Reputation: 2
#8
RE: Rotate entity fixed amount of degrees

(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

My mod Amadeus
(This post was last modified: 03-28-2014, 07:17 PM by Reminiscity.)
03-28-2014, 06:54 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#9
RE: Rotate entity fixed amount of degrees

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: (Select All)
RotatePropToSpeed("ts_vinyl_1"5.0f5.0f0.0f, -360.0f0.0ffalse""); 
And the object's settings looked like this:
Spoiler below!
[Image: rotate_entity.png]

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.

(This post was last modified: 03-28-2014, 08:13 PM by Mudbill.)
03-28-2014, 08:10 PM
Find
Reminiscity Offline
Member

Posts: 81
Threads: 16
Joined: Jan 2013
Reputation: 2
#10
RE: Rotate entity fixed amount of degrees

(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.

I once made an entity that was continuously rotating in a loop. I used the script
PHP Code: (Select All)
RotatePropToSpeed("ts_vinyl_1"5.0f5.0f0.0f, -360.0f0.0ffalse""); 
And the object's settings looked like this:
Spoiler below!
[Image: rotate_entity.png]

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.

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.

My mod Amadeus
03-28-2014, 10:00 PM
Find




Users browsing this thread: 1 Guest(s)