Welcome, Guest! Login | Register

Player-guided weapons [Print this Article]
Posted by: wil5on
Date posted: Jul 18 2004
User Rating: N/A
Number of views: 2596
Number of comments: 3
Description: Make the RPG like the UT redeemer, easy!
Basically to get the players view from the weapons position, you need to use SET_VIEW when the projectile is created, and SET_VIEW again when its destroyed. For example:

 CODE  

if (m_pPlayer)
    SET_VIEW( m_pPlayer->edict(), edict() );


Stick this into a projectiles think function for flying. Make sure you set up m_pPlayer as a pointer back to the player who fired the rocket (CBasePlayer *m_pPlayer), and set it in the function where the weapon gets fired.

Heres the code neccessary to make it guidable:

 CODE  

UTIL_MakeVectors( m_pPlayer->pev->v_angle );
pev->angles = m_pPlayer->pev->v_angle;
pev->velocity = gpGlobals->v_forward * 500;


This just sets the projectiles angles and velocity to match the direction the players looking. I chose 500 there because I think its a good speed for a Redeemer rocket, you can change that to whatever.

Finally, you have to set the players view back to the player, so in whatever function gets called when the projectile hits something, stick this:

 CODE  

SET_VIEW( m_pPlayer->edict(), m_pPlayer->edict() );


Well, thats all you really need to know. Have fun, and happy coding!

Rate This Article
This article has not yet been rated.

You have to register to rate this article.
User Comments Showing comments 1-3

Posted By: XWider on Feb 13 2005 at 02:25:07
IMHO, Everyone knows that..

Posted By: paccer on Feb 15 2005 at 15:31:00
i'd like a guide on how to do in hl2 :)Edited by paccer on Feb 15 2005, 15:32:55

Posted By: kapalkaudi on Feb 20 2005 at 12:08:06
Nice snippet


You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 04 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
Where do we go from here
General | News
By: MIFUNE | Jun 09 2008
 
The Input/Output system
Half-Life 2 | Level Design
By: nazitaco | Dec 23 2007
 
Where do we go from here
General | News
By: Rob_F | Nov 22 2007
 
Rescaling Half-Life
Half-Life | Coding | Shared Tutorials
By: christoph | Nov 12 2007
 
GameUI
Half-Life 2 | Coding | Client Side Tutorials
By: Evil_j | Oct 29 2007
 
3 State Zoom For Any Weapon
Half-Life 2 | Coding | Server Side Tutorials
By: Ennuified | Oct 18 2007
 
Storing weapons on ladder
Half-Life 2 | Coding | Snippets
By: cct | Sep 07 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: DarkNight | Aug 28 2007
 
CTF Gameplay Part 1
Half-Life | Coding | Shared Tutorials
By: deedok | Aug 20 2007
 
Debugging your half-life 2 mod
Half-Life 2 | Coding | Articles
By: blackshark | Aug 17 2007
 

Site Info
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (14 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!