Room that pushes the player out. - by vfig
vfig on 26/5/2020 at 15:13
I'm trying to set up a room that, when the player enters, it will push them smoothly back out again. I also need to turn this behaviour off later so the player can pass through the room.
I've got a rough version of this working where the room is actually water and using a flow brush for the current—but it's an awful hack to make the water transparent and the player not have to breathe and to replace the underwater loop with silence. Also I'm not sure if with flow brushes that I could turn it off later.
More importantly, I also want to have ordinary underwater areas in this mission, so messing with the normal player-in-water behaviours will cause other problems.
Any ideas?
Tannar on 26/5/2020 at 15:26
Could you not just use gravity and change the axis to X or Y?
Balboa on 26/5/2020 at 15:36
I did that in Ladytaker. Use an Emit trap to push the player out of the room. It's OK to push more gently than I did. :ebil:
trefoilknot on 26/5/2020 at 15:40
You could also use trapmoverelative and an nvrelaytrap with nvrelayrepeat to make it nudge the player over and over. It should be easy to make the it feel like being smoothly pushed in one direction.
vfig on 26/5/2020 at 15:49
Quote Posted by Tannar
Could you not just use gravity and change the axis to X or Y?
I could change the gravity %, but there isn't a gravity axis property that I'm aware of.
Quote Posted by Balboa
I did that in Ladytaker. Use an Emit trap to push the player out of the room. It's OK to push more gently than I did. :ebil:
So just continually emitting physics objects at the player to push them? Hmm, interesting.
Quote Posted by trefoilknot
You could also use trapmoverelative and an nvrelaytrap with nvrelayrepeat to make it nudge the player over and over. It should be easy to make the it feel like being smoothly pushed in one direction.
TrapMoveRelative is setting the target's PhyState velocity. I tried doing that too, but got horribly jerky results. But I see that TrapMoveRelative is also teleporting the target (even if its position is not moving) immediately before, which I guess causes the physics engine to discard the target's entire physics state? I'll try doing that too. Thanks!
ZylonBane on 26/5/2020 at 15:57
This is trivial with a script. Just set the player's velocity to fling them out the door.
Code:
class flingPlayer extends SqRootScript {
function OnTurnOn() {
Physics.SetVelocity("Player", vector(1, 0, 0));
}
}
Also should probably bracket the door with invisible physics walls so sufficiently determined players can't catch themselves on the edge of the door frame.
Balboa on 26/5/2020 at 16:15
Quote Posted by vfig
So just continually emitting physics objects at the player to push them? Hmm, interesting.
No, you emit the
player out of the emitter trap. in the direction opposite to the way they were going. Choose any velocity that feels seamless.
vfig on 26/5/2020 at 16:16
Doing a teleport before setting the PhyState (as TrapMoveRelative does) worked nicely, and got rid of the horrible jerks.
Quote Posted by ZylonBane
This is trivial with a script. Just set the player's velocity to fling them out the door.
Code:
class flingPlayer extends SqRootScript {
function OnTurnOn() {
Physics.SetVelocity("Player", vector(1, 0, 0));
}
}
And this is even better! Teleporting has side effects, and this way I don't have to suffer them. I'd forgotten about the Physics script service. Thank you, ZylonBane!
Quote Posted by Balboa
No, you emit the
player out of the emitter trap. in the direction opposite to the way they were going. Choose any velocity that feels seamless.
:eek:
I don't think I'd ever have thought of emitting the player! Useful to know. But the physics-based method works better for me here, as I can start the pushback gently and increase it over time so that it feels more like a constant force than a sudden change of velocity.