General Half-Life 2/Effects
description
Control the player view in an advanced way.
keywords
player view, view, viewcontrol, point_viewcontrol, camera.
What we will achieve:
This tutorial will teach you how to work with the players viewcontrol and create a more advanced scene than you could ever achieve with a point_viewcontrol following paths.
This is a quick, but informative tutorial on how Valve does their scenes where the players view is tweaked to create a more intruiging scene (in general).
You can create you're own animations for it if you are familiat with animation and have a application that supports it: 3ds Max, XSI, Maya etc.
How it works, and how to make it work
First off, lets talk about just how it works and what makes it work.
Its all about parenting and taking over the players view.
Yes you guessed it, point_viewcontrol.
What happends is, a model with a premade animation has a bone called "Blackout.view" which is attached to a player "ghost" or a simple bone rig if you like.
- Code: Select all
$attachment "vehicle_driver_eyes" "Blackout.view"
is the code in the .QC that makes this happend.
The vehicle_driver_eyes is used with a animation whenever the playerview needs to be moved in a special way.
A example of this, is when you enter and exit a vehicle.
That is simply a model with two/three bones (Blackout.view, Blackout.base and in OB, Blackout.attach).
Then these bones are moved around, creating a animation. And remember that, Blackout.view is the bone that represents the players eyes.
That is why "vehicle_driver_eyes" is attached to that specific bone. So whatever you do with that bone in a 3d/animating application, happends with the player view
in game. But I made it sound easier then it really is.
How do you get that specific animation to play?
Well, first off, lets use the HL2 Blackout scene/animation as reference.
These entities are needed for making it happend:
- point_viewcontrol
- trigger(s) (logic_relay)
- info_teleport_destination
- trigger_teleport
- prop_dynamic
You can also add env_fade's and other entities to create a more realistic/prettier effect.
Now, how to set it all up.
point_viewcontrol:
Name: playereyes_viewcontrol
Then go to "Flags" and check: Freeze Player, Infinite Hold Time and Snap to goal angles.
Uncheck all else.
prop_dynamic:
Name: playereyes_model
World Model: models/blackout.mdl
Pitch Yaw Roll: the view in the model is facing with the X axis. Rotate to whatever you need.
Collisions: Not Solid
Leave the rest at default.
Then we'll add one output parameter:
- Code: Select all
OnAnimationDone - player_teleport_trigger - Enable - [BLANK] - 0.00 - No
info_teleport_destination:
Name: Teleport_destination
This entity will decide where you end up when you get control of the player again.
trigger_teleport:
Make a brush that you can ensure the player is IN when you get control of the player. Then tie it to "trigger_teleport"
Name: player_teleport_trigger
Start Disabled: Yes
Remote Destination: Teleport_destination (the info_teleport_destination entity we just made).
Leave all else at default.
Check "clients" under "Flags".
Then we are going to add a few output parameters:
- Code: Select all
OnStartTouch - player_teleport_trigger - Disable - [BLANK] - 0.00 - No
OnStartTouch - playereyes_viewcontrol - Disable - [BLANK] - 0.00 - No
OnStartTouch - playereyes_viewcontrol - Kill - [BLANK] - 0.20 - No
OnStartTouch - playereyes_model - Kill - [BLANK] - 0.20 - No
Logic_Relay
Name: relay_playerevent
Then some outputs:
- Code: Select all
OnTrigger - playereyes_viewcontrol - SetParent - playereyes_model - 0.00 - No
OnTrigger - playereyes_viewcontrol - SetParentAttachment - vehicle_driver_eyes - 0.10 - No
OnTrigger - playereyes_viewcontrol - Enable - [BLANK] - 1.00 - No
OnTrigger - playereyes_model - SetAnimation - exit1 - 1.20 - No
Now trigger the logic_relay with a trigger_once over the player spawn forexample. Or any way you wish.
A simple one would be like this:
- Code: Select all
OnTrigger - relay_playerevent - Trigger - [BLANK] - 0.00 - No
Then you're done! Add extra effects to make it looks prettier.
===================================
Alright, lets talk abit about what we have done.
On the prop_dynamic, we added this output:
- Code: Select all
OnAnimationDone - player_teleport_trigger - Enable - [BLANK] - 0.00 - No
What this means, is that, when the animation has stopped playing, we enable the teleport_trigger.
This is why you need to be located in it when the animation ends, because you will be immediatly teleported to the destination you will receive control over the player again.
Now, on the trigger_teleport, we added these outputs:
- Code: Select all
OnStartTouch - player_teleport_trigger - Disable - [BLANK] - 0.00 - No
OnStartTouch - playereyes_viewcontrol - Disable - [BLANK] - 0.00 - No
OnStartTouch - playereyes_viewcontrol - Kill - [BLANK] - 0.20 - No
OnStartTouch - playereyes_model - Kill - [BLANK] - 0.20 - No
What happends here is; when the teleport_trigger is enabled after the animation is done, we teleport, and immediatly disable it, at the same time we disable the point_viewcontrol. In other words, we get control of the player, where we want him. Then shortly after (0.20 seconds to be precise), we kill the entities we dont need anymore. Being the camera, and the model.
Alright, the last one. The logic_relay got these outputs:
- Code: Select all
OnTrigger - playereyes_viewcontrol - SetParent - playereyes_model - 0.00 - No
OnTrigger - playereyes_viewcontrol - SetParentAttachment - vehicle_driver_eyes - 0.10 - No
OnTrigger - playereyes_viewcontrol - Enable - [BLANK] - 1.00 - No
OnTrigger - playereyes_model - SetAnimation - exit1 - 1.20 - No
The point_viewcontrol is parented to the prop_dynamic itself, so it moves with it. But we also need it to be parented to a attachment bone. Being: vehicle_driver_eyes.
So there we got it properly parented and it will move with the "head" in the animation (Blackout.view bone).
The third one speaks for itself. We enable it so we can use the point_viewcontrol as our viewpoint.
Shortly after, we start the animation. The animation where you rise from being knocked down, is called exit1.
So when its done playing, we terminate the point_viewcontrol, triggers and unused entities, and regain control of the player after the animation.
Hope you find it useful. Decompile the "Blackout.mdl" and import any of the smd's and make you're own animation if you want to. I did, and it works perfectly.
Just enter a new sequence:
- Code: Select all
$sequence myanimation "myanimation" fps 30
Example map: examplemap.rar
Garrador