How do you make a Player Stand on a moving object?
Blitz3D Forums/Blitz3D Programming/How do you make a Player Stand on a moving object?
| ||
I searched around the forums, but can't find anything about how to make a player move around independently on another moving object (say a boats deck). The player could be in both first and third person mode. I'm guessing, but would I move the boat in one direction and then move the player in the same direction? Any ideas? |
| ||
This is prolly not the best way to do it, but Im sure it'd work and it's how I'd approach the problem: CHECK IF player TOUCHING object IF SO: ENTITYPARENT player,object ENDIF IF NOT: UNPARENT player,object (Depending on your style of game, this should work for a player jumping/ falling running etc. Also, it won't matter at which point they collide with the ship's deck... |
| ||
Or use the mighty tokamak. |
| ||
I do a linepick down and parent the player's pivot to any entity immediately below it or unparent it if there is nothing below. I did this in SARE engine and it worked a treat for lifts,it even rotated the player if they were on a rotating platform and it all worked seamlessly. If the player is jumping or falling then unparent them. |
| ||
do you want the player to be able to 'walk' around the boat? |
| ||
Look in the Toolbox for Nuclear Glory collision detection. |
| ||
Yes, I want the player to walk around on the boat. Would the EntityParent/LinePick method or Nuclear Glory allow this? I'm trying to avoid physics;) |
| ||
Do something like; in every loop: playercollide=EntityCollided(player,object type) When you move an object that the player might stand on, check if playercollide=objecthandle, if so, move the player along. It's a bit more difficult if you rotate the object, but as far as you call yourself "integraldragon", you better be able to do a bit of trigonometry yourself. Hope it helps :) |
| ||
I'd do it with parenting, until the player is not colliding with the boat any more. |
| ||
Shambler - could you post a simple example in de code archives? Sounds good! |
| ||
Hmmm bit too hard to rip that out of the engine since it relies on many other things in the engine =/ Would have to write something from scratch, will see if I get the time... |
| ||
Parenting/unparenting would not be perfect however. I can think of many scenarios where it wouldn't look correct. Imagine if the player is riding in a speed boat. The player decides to jump straight up into the air. In reality: the player would continue to follow the motion of the boat and land only slightly behind where he started the jump (due to wind resistance). Parented the whole time: the player would continue to follow the motion of the boat and land exactly where he started the jump. Unparented once jump began: the player would move up as the boat would swiftly ride forward out in front of him. Probably best to keep the player parented or use a physics system. |
| ||
This could be overcome by adding the boats velocity to the players velocity at the moment of jumping and unparenting. |
| ||
What he said. :) |