Advanced Player View Control

Tutorial collection, comprehensive listings on main site.

Advanced Player View Control

Postby Tutorial on Sun Apr 27, 2008 9:10 pm

category
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.

Image

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
in the .QC file.

Example map: examplemap.rar

Garrador
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Re: Advanced Player View Control

Postby Oakley on Sun Apr 27, 2008 9:22 pm

IWANTSEXNOWPLEASE

Sorry but I have been waiting for this tutoial, i've tied so many times and I just can't get it to work properly. I will go try now.

i love you
User avatar
Oakley
1337 p0st3r
1337 p0st3r
 
Joined: Mon May 28, 2007 11:05 pm
Location: The Internets

Re: Advanced Player View Control

Postby Garrador on Thu May 01, 2008 6:37 pm

I'm glad :)

Did you get it working properly. Blackout animations cant be used in OB if I remember correctly.
But you can just look at what sequences the model have for each version.
User avatar
Garrador
Veteran
Veteran
 
Joined: Fri May 12, 2006 10:39 pm
Location: Norway

Re: Advanced Player View Control

Postby HappyNoodleboy on Tue May 20, 2008 6:21 am

Hey. I successfully decompiled the blackout.mdl. I also added my own animation on the "veiw" null. The problem is when I export the skeleton.smd file it creates a 1kb file of nothing. The only animation is on the veiw null do i need animation elsewhere? Is tehre a particular export setting for getting the animation into hammer? There are 3 check boxes in the valve export plugin for xsi:

Optimize Chains and Compensate

Remove top-level bone from character rig

Drop any unused bones

I usually un-check the middle one. Is there a better way?

I am using XSI 6.2 and I can export animations for other models i created but not for this one.

By the way I am only exporting skeleton animations and I have left all the other smd's alone.
HappyNoodleboy
Member
Member
 
Joined: Sun Mar 09, 2008 9:25 pm

Re: Advanced Player View Control

Postby HappyNoodleboy on Sun May 25, 2008 9:42 pm

Ok I got everything to work properly but I am stuck at the very end. When the camera animation is done my character gets teleported just like he's supposed to, but he is frozen. no movement from the cam or player.

I have the player_teleport_trigger as such:

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

nothing happens though. Is there something Im missing?
HappyNoodleboy
Member
Member
 
Joined: Sun Mar 09, 2008 9:25 pm

Re: Advanced Player View Control

Postby Fearian on Tue May 27, 2008 4:23 am

where the fuck did you manage to get this from? :D

brilliant stuff man. thanks!
User avatar
Fearian
May Contain Skills
May Contain Skills
 
Joined: Wed Nov 30, 2005 10:33 pm

Re: Advanced Player View Control

Postby Garrador on Tue May 27, 2008 7:56 pm

HappyNoodle: He teleports but is frozen? Be sure you named all entities right, and look over all outputs/inputs. Also look at timing.
Maybe you also have a lot of frames in the end of the animation? Meaning, it still plays the animation.

Fearian: Decompiling map, reading entity input/outputs, testing, animating, testing :P
Took a little while, but found out the logic in it. Rather simple tbh :P Just need to figure it out first. Which ofcourse is the hard part :P

Thanks, hope it's useful!
User avatar
Garrador
Veteran
Veteran
 
Joined: Fri May 12, 2006 10:39 pm
Location: Norway

Re: Advanced Player View Control

Postby TheLinx on Sat Jun 21, 2008 8:57 pm

I can't get it to work :/

Is it because it's on the OB engine?
Here's my VMF file: http://upl.vs-hs.com/d/94d1
User avatar
TheLinx
Member
Member
 
Joined: Sat Jun 21, 2008 12:40 pm

Re: Advanced Player View Control

Postby Garrador on Sat Jun 21, 2008 9:43 pm

those triggers should have a the trigger texture on ;)
tool < trigger
User avatar
Garrador
Veteran
Veteran
 
Joined: Fri May 12, 2006 10:39 pm
Location: Norway

Re: Advanced Player View Control

Postby Alters on Thu Jul 03, 2008 1:01 pm

Also can't get it to work, there is no exit1 animation, using OB.
Alters
Member
Member
 
Joined: Wed Jun 25, 2008 12:28 am

Re: Advanced Player View Control

Postby Garrador on Tue Jul 15, 2008 11:40 pm

Well, if you use OB, find "blackout.mdl" in mdlviewer, then you can see what animations it contains.
I havent checked yet, what anims it has and what is does not have.

PM me if you are having trouble with anything else, I'll see if I can help you then, and post solutions later on.
User avatar
Garrador
Veteran
Veteran
 
Joined: Fri May 12, 2006 10:39 pm
Location: Norway

Re: Advanced Player View Control

Postby SM Sith Lord on Thu Mar 06, 2014 1:32 pm

I wish to do this completely from C++ code. What is the proper way to do it? Should I be creating all these entity setups using code, or is there a more direct way?

EDIT:
Okay, this is what I came up with as my best guess so far:

1. I create a new animation model called "arcade_anims.mdl" that has a bone to attach the camera to and some different animation sequences to play.

2. When triggered, I spawn this MDL as a prop_dynamic on my arcade cabinet, then create a point_viewcontrol and parent it to the prop_dynamic, attached at the bone.

3. Now I activated the point_viewcontrol and play the desired sequence (it will depend on the arcade cabinet).

4. Clean up involves de-activating the point_viewcontrol and deleting all entities that I created on-the-fly.

This method will allow the animations to be stored separately from the cabinet models themselves, which I assume is what Valve's blackout.mdl is all about.
SM Sith Lord
Been Here A While
Been Here A While
 
Joined: Sat Nov 25, 2006 4:25 pm
Location: Los Angles, CA

Re: Advanced Player View Control

Postby Garrador on Sat Mar 08, 2014 12:22 am

SM Sith Lord wrote:I wish to do this completely from C++ code. What is the proper way to do it? Should I be creating all these entity setups using code, or is there a more direct way?

EDIT:
Okay, this is what I came up with as my best guess so far:

1. I create a new animation model called "arcade_anims.mdl" that has a bone to attach the camera to and some different animation sequences to play.

2. When triggered, I spawn this MDL as a prop_dynamic on my arcade cabinet, then create a point_viewcontrol and parent it to the prop_dynamic, attached at the bone.

3. Now I activated the point_viewcontrol and play the desired sequence (it will depend on the arcade cabinet).

4. Clean up involves de-activating the point_viewcontrol and deleting all entities that I created on-the-fly.

This method will allow the animations to be stored separately from the cabinet models themselves, which I assume is what Valve's blackout.mdl is all about.


That solution seems like the best and most simple one. If you do it in code you'd have more control in any case. The "vehicle_driver_eyes" bone is "hardcoded", which is why one must use it if no coding should be involved. However, you could set it up how you'd like.

Any bone rig with an animation would do in this case, so I'm sure your solution works just fine. Post back if it works as expected ;)
You click on Build or type
make (or some equivalent), and you are astonished, then mortified, as you realize that the whole world is being
recompiled and relinked!
- Scott Meyers
User avatar
Garrador
Veteran
Veteran
 
Joined: Fri May 12, 2006 10:39 pm
Location: Norway

Return to Tutorials

Who is online

Users browsing this forum: No registered users