Welcome to PlagueFest.com! Log in or Sign up to interact with the Plague Fest community.
  1. Welcome Guest! to interact with the community and gain access to all the site's features.

Resource Driveable vehicles that do not depend on sv_turbophysics 0

Discussion in Resources & Tutorials started by enviolinador, Apr 25, 2013

  1. May 31, 2012
    Posts
    One of the issues of driveable vehicles is that they usually depend on turbophysics being 0 to physically collide with the player and allow movement within the player-physics system. There were maybe some workarounds (using, for example, tracktrains) but those tend to be harder to control due to the fact that they don't 'care' about where they are. A common thing to think was to parent players to the vehicle, but parenting players in most cases translates into crashes.

    Trying to get driveable vehicles working to an acceptable degree, I thought about using logic_measure_movement. It allows to 'parent' entities outside of the normal parenting hierarchy, and doesn't come with crashes if applied to a player. However, it only parents one entity at a time, so a vehicle would have needed 64 logic_measure_movements and some tedious filtering.

    The other issue with driveable vehicles is that they tend to lag a lot, but this is a direct effect of turbophysics 0 or, if not turbophysics, at least collisions with complicated brush-based vehicles.

    To find a solution I started playing with the parenting hierarchy and to my surprise I found that players can only be parented without crashing to persistent entities, such as func_brushes. The issue is that persistent entities can't be parented to non-persistent ones, as if so is done they'll disappear after one round. They can, however, be tied to an entity using logic_measure_movement.

    As you can understand from this, a normal vehicle with the mentioned brush + measuremovement can be built, so a player can be parented to it. The parented player is still able to move, so it will need to get its speed changed to 0 (a player_speedmod does it just fine).

    For the lag issues and the odd cameraviews only a solution really satisfied me: using point_viewcontrols. They are persistent entities too, so they have to follow the same weird parenting system (using measure movements). However, they do a really nice job in terms of creating the illusion of driving; I think so at least.

    There are to problems that come by hand with those two solutions/workarounds: players' parents are kept between rounds (which seems to cause them to spawn away from spawn) and point_viewcontrols aren't reset from round to round (meaning that you'll have to force it to get disabled). To finally fix that, a simple game_zone_player can be called at map spawn to teleport back players outside the spawn area, reset parentnames and disable viewcontrols.

    I am attaching a simple test map. The car is not solid and you're probably missing the sounds. The model can be found at Natalya's webpage, http://www.lady-natalya.info/downloads/car_pack_v2.zip. It would need further polishing, as it is just a little test of mine to get a car that automatically increases its speed, has driver/copilot seats and 'works'. The speed could be increased and probably a trigger_hurt should be added to its front. The I/O within entities is a bit of a mess, so I hope you understand what is going on (it has some duplicated outputs and some of them aren't necessary, but they were during the tests)

    The attached .rar file includes both the .vmf and the .bsp. I'd be grateful if it wasn't used as a prefab, but more of a learning tool since I feel it's kinda terrible. If I can help you with anything, or you want to tell me that I'm wasting entities like a mofo on this, do not hesitate to do so, but I already know about the whole entities thing.

    Mediafire link for cool peeps: http://www.mediafire.com/?lld0ais764f0d8x

    Attached Files:

    • Mapping King Mapping King x 1
      enviolinador, Apr 25, 2013 Last edited by enviolinador, May 6, 2013
    • May 14, 2011
      Posts
      Nice find!