Terasology / LightAndShadow

Light & Shadow is an experimental game type set in a quirky Alice in Wonderland inspired setting
Apache License 2.0
8 stars 22 forks source link

Push away from dome #52

Closed krishnarb3 closed 7 years ago

krishnarb3 commented 7 years ago

Fixes #6
The magic dome now pushes player outside if trying to come in and pushes back inside if trying to go out. Also higher the altitude lesser the Y component of the impulse to prevent player from being pushed away too much.

Cervator commented 7 years ago

Tried testing this, but am having trouble finding my way outside. Attempted teleport a few times but either ended up in the wrong spot of squished from insta-impulsing around. Tried to fly out of the stop but also got stuck in some weird impulse pushing loop.

@krishnarb3 how did you go about testing it the best way?

@skaldarnar & @msteiger: poke! Sending this your way for further review, testing, and hopefully merging :-)

krishnarb3 commented 7 years ago

The issue with this is that teleport is seen as a movement, hence impulse acts as if the player moved from coordinate 1 to coordinate 2. I tested by commenting out one part while testing the other (Eg: for testing impulse when player enters from outside, I commented out the impulse part for magic dome pushing player inside). This can be solved by checking if the player is teleporting and disabling the magic dome at that moment alone. Any suggestions on how to do that i.e. How to check if he is teleporting?

Cervator commented 7 years ago

So looking real quick in ServerCharacterPredictionSystem method onTeleport handles the CharacterReleportEvent - possibly you could just add your own higher priority event handler somewhere in the Magic Dome System that could set a flag or take some other action to avoid the impulse?

skaldarnar commented 7 years ago

This is scheduled on my TODO list once I've got a stable internet connection again. Can't wait to test that out 😄

krishnarb3 commented 7 years ago

Hello I am still stuck on disabling all other events if he/she is teleporting. Could someone help me with that? Thanks.

skaldarnar commented 7 years ago

Hi @krishnarb3, sorry for the long delay. I just managed to test this out, looks good to me.

For testing, I shifted the dome away from player's spawn position so that I spawned outside. This is not ideal, but anyways.

A possible solution to our problem might be not only check the player's before and after position, but also the velocity. By adding the following line to onTeleport the player's velocity will be canceled on teleport (thus, teleport will be a change of position without change of velocity):

newState.setVelocity(Vector3f.zero());

I'm not sure about other implications of this change, though.

Cervator commented 7 years ago

@skaldarnar are you good with merging this since you approved? Just hit the button or push from local in that case, no need to wait :-)

Can always submit a follow-up issue if this is stable enough to merge then do a round two later.