How to make spinning objects. [PROBLEM SOLVED]

Kunny

L2: Junior Member
Jan 2, 2017
80
9
I am trying to make a spinning object in hammer that will push players that block it. So far I have only found ways to make brushes spin, but when they collide into a player it just passes right through them. I have tried using a func_rotating aswell and I have tried using func_physbox + phys_motor.
 

Da Spud Lord

Occasionally I make maps
aa
Mar 23, 2017
1,339
994
What Megapie is referring to is A Boojum Snark's solution, but I don't think that will work as I believe momentary_rot_button also passes through players.

The solution I used in my map koth_skyfall was a func_door_rotating that worked similar to ABS' solution. I wanted a rotating platform that could push players off of it. Under ordinary circumstances, players will just block this object's rotation when they even so much as lightly touch it. But, when the "Force Closed" keyvalue is set to Yes, the door will push players that block its movement, but only when the door is closing. So my solution was to make the door close infinitely. Unfortunately, doors can't do that. Fortunately, we can work around this by using a solution similar to ABS'.

Create your rotating door. Set the name to whatever you want. For simplicity, you can give all of the rotating doors using this method the same name. Set your distance to any multiple of 360 you want. Set your speed to whatever you want. Set "Force Closed" to Yes. Make sure the "Starts Open" flag is checked. Then head to the Outputs tab and create the following outputs:
My Output|Target Entity|Target Input|Parameter|Delay|Only Once
OnFullyOpen|!self|SetSpeed|<speed*>|0.00|No
OnFullyOpen|!self|Close||0.00|No
OnFullyClosed|!self|SetSpeed|99999**|0.00|No
OnFullyClosed|!self|Open||0.00|No
*Replace <speed> with whatever speed you want the object to rotate at.
**This can be any ridiculously high number.

Now, go to your logic_auto entity (create one if you don't have one yet) and add this output:
My Output|Target Entity|Target Input|Parameter|Delay|Only Once
OnMapSpawn|<func_door_rotating name*>|Close||0.00|No
*Replace <func_door_rotating name> with the targetname of your rotating object. If your rotating objects have different names, you'll need to create multiple outputs here, one for each rotating object.

Looks fancy, but what does it do? How does it work? This is what all this logic does:
1. When your map first loads, the door starts closing. This is the start of normal rotation.
2. When it reaches the fully closed position, the door stops because it can't rotate any further. To allow it to rotate, it needs to open, so it tells itself to open. But we don't want the player to see the door opening, so before it opens, it sets its speed to a super high number so that it opens super fast. The door should open so fast that no player will ever even notice it stopping or opening. If you set your door's speed to a multiple of 360, the open and close positions should be functionally the same, so the rotation remains seamless.
3. Once the door is fully opened, it sets its speed back to normal and tells itself to close. The cycle restarts at step 2.
 

Kunny

L2: Junior Member
Jan 2, 2017
80
9
What Megapie is referring to is A Boojum Snark's solution, but I don't think that will work as I believe momentary_rot_button also passes through players.

The solution I used in my map koth_skyfall was a func_door_rotating that worked similar to ABS' solution. I wanted a rotating platform that could push players off of it. Under ordinary circumstances, players will just block this object's rotation when they even so much as lightly touch it. But, when the "Force Closed" keyvalue is set to Yes, the door will push players that block its movement, but only when the door is closing. So my solution was to make the door close infinitely. Unfortunately, doors can't do that. Fortunately, we can work around this by using a solution similar to ABS'.

Create your rotating door. Set the name to whatever you want. For simplicity, you can give all of the rotating doors using this method the same name. Set your distance to any multiple of 360 you want. Set your speed to whatever you want. Set "Force Closed" to Yes. Make sure the "Starts Open" flag is checked. Then head to the Outputs tab and create the following outputs:
My Output|Target Entity|Target Input|Parameter|Delay|Only Once
OnFullyOpen|!self|SetSpeed|<speed*>|0.00|No
OnFullyOpen|!self|Close||0.00|No
OnFullyClosed|!self|SetSpeed|99999**|0.00|No
OnFullyClosed|!self|Open||0.00|No
*Replace <speed> with whatever speed you want the object to rotate at.
**This can be any ridiculously high number.

Now, go to your logic_auto entity (create one if you don't have one yet) and add this output:
My Output|Target Entity|Target Input|Parameter|Delay|Only Once
OnMapSpawn|<func_door_rotating name*>|Close||0.00|No
*Replace <func_door_rotating name> with the targetname of your rotating object. If your rotating objects have different names, you'll need to create multiple outputs here, one for each rotating object.

Looks fancy, but what does it do? How does it work? This is what all this logic does:
1. When your map first loads, the door starts closing. This is the start of normal rotation.
2. When it reaches the fully closed position, the door stops because it can't rotate any further. To allow it to rotate, it needs to open, so it tells itself to open. But we don't want the player to see the door opening, so before it opens, it sets its speed to a super high number so that it opens super fast. The door should open so fast that no player will ever even notice it stopping or opening. If you set your door's speed to a multiple of 360, the open and close positions should be functionally the same, so the rotation remains seamless.
3. Once the door is fully opened, it sets its speed back to normal and tells itself to close. The cycle restarts at step 2.
What if I wanted to toggle the spinning object on and off with a button.
 

Yrr

An Actual Deer
aa
Sep 20, 2015
1,308
2,743
Have two doors alternating their direction.
Parent an object to the one opening in the direction you want it to rotate.
OnFullyOpen, parent it to the other door instead.

Your object will now always be parented to a door opening in the direction you want it rotating.
(Or closing, whichever you want)
 

Da Spud Lord

Occasionally I make maps
aa
Mar 23, 2017
1,339
994
What if I wanted to toggle the spinning object on and off with a button.
The lock and unlock inputs on the door should work. I don't know if this will make the door stop partway through its rotation, though. If that doesn't work, try setting the speed to 0.