NPCs And Vehicles

Hey again people, I’ve been experimenting with NPCs recently, and when I decided to try parenting NPCs to vehicles, I hit a bit of a brick wall. I am using a custom vehicle, in this case a jeep ripped from S.T.A.L.K.E.R, with a custom vehicle script. The issue comes about when I attempt to parent an NPC to it, to give the illusion that someone is driving the vehicle, instead of an invisbile npc_vehicledriver.

I parent the NPC to the vehicle via a logic_relay, but he teleports to a location a couple of miles away from his scripted_sequence. I have tried parenting both the sequence and the NPC, only one or the other and parenting either or both to a second model parented to the vehicle, but nothing changes it. The second issue is that when the map restarts, the NPC doesn’t teleport, but sinks through the vehicle to the ground as if he is not parented to it.

I believe the issue may be that the model was, for some strange reason rotated 90 degrees on it’s origin during the creation, meaning the actual entity faces 90 degrees to the right, not straight, but this fails to explain exactly why this occurs. On a side note, when the NPC teleports, he still acts as if he is parented to the vehicle, moving with it and following it’s movements.

I could also benefit from somebody assisting the animation of the NPC. At the moment, he is using a placeholder animation from Half Life 2, the trainride sitting animation to be precise. This works effectively, but looks slightly off as his arms clip through the steering wheel, and he makes no movements as if he were steering the vehicle. I have thought that perhaps I could model the driver onto the vehicle, so that animations could be included for the driver turning the steering wheel or accelerating.

Thanks in advance to anyone who can help!

make sure that betwen teleporting and parenting him there is at LEAST a 0.1 second delay.

If the NPC doesn’t have to do much, you’re probably way better off using an animated prop_dynamic entity or npc_furniture entity. You can command the prop_dynamic to perform all kinds of animations in relationship to what the vehicle is doing.