Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 03-27-2009, 03:57 PM   #1
FeareD
 
Guest
Posts: n/a
Make the bullet shoot at the crosshair??

This is for my third person over the shoulder mod.

Basically i want the bullet to hit at where the crosshair is and only were the crosshair is.


I found
Vector CBasePlayer::Weapon_ShootPosition( )

But I am clueless I have spent a few hours wondering around and got no where.

How would I go about making the bullet hit where the crosshair is?

Please don't go off topic!
 
Reply With Quote
Old 03-27-2009, 05:20 PM   #2
Winston
 
Join Date: Jul 2007
Reputation: 84
Posts: 2,170
Shoot position is where the bullet starts iat. You want to affect the angle its fired at, which iirc is specified in each weapon's primary attack function
Winston is offline   Reply With Quote
Old 03-27-2009, 05:44 PM   #3
FeareD
 
Guest
Posts: n/a
Quote:
Originally Posted by Winston View Post
Shoot position is where the bullet starts iat. You want to affect the angle its fired at, which iirc is specified in each weapon's primary attack function
Alright I see that.
Code:
		pPlayer->entindex(),
		pPlayer->Weapon_ShootPosition(),
		pPlayer->EyeAngles() + pPlayer->GetPunchAngle(),
But now I'm confused?

Any Help?

It's probably staring at me right in the face.

And yes I did look at

Code:
void CHudCrosshair::Paint( void )
{
	if ( !m_pCrosshair )
		return;

	if ( !IsCurrentViewAccessAllowed() )
		return;

	m_curViewAngles = CurrentViewAngles();
	m_curViewOrigin = CurrentViewOrigin();

	float x, y;
	x = ScreenWidth()/2;
	y = ScreenHeight()/2;

	// MattB - m_vecCrossHairOffsetAngle is the autoaim angle.
	// if we're not using autoaim, just draw in the middle of the 
	// screen
	if ( m_vecCrossHairOffsetAngle != vec3_angle )
	{
		QAngle angles;
		Vector forward;
		Vector point, screen;

		// this code is wrong
		angles = m_curViewAngles + m_vecCrossHairOffsetAngle;
		AngleVectors( angles, &forward );
		VectorAdd( m_curViewOrigin, forward, point );
		ScreenTransform( point, screen );

		x += 0.5f * screen[0] * ScreenWidth() + 0.5f;
		y += 0.5f * screen[1] * ScreenHeight() + 0.5f;
	}

	m_pCrosshair->DrawSelf( 
			x - 0.5f * m_pCrosshair->Width(), 
			y - 0.5f * m_pCrosshair->Height(),
			m_clrCrosshair );
}

Last edited by FeareD: 03-27-2009 at 05:47 PM.
  Reply With Quote
Old 03-27-2009, 06:03 PM   #4
z33ky
 
Join Date: May 2008
Reputation: 169
Posts: 5,361
You could either re-position the crosshair by shooting a traceline and putting it at the end, or you'll have to use some trigonometry where the shooting-angles are determined as you've probably re-positioned and rotated the camera.
z33ky is offline   Reply With Quote
Old 03-27-2009, 06:10 PM   #5
FeareD
 
Guest
Posts: n/a
Quote:
Originally Posted by z33ky View Post
You could either re-position the crosshair by shooting a traceline and putting it at the end, or you'll have to use some trigonometry where the shooting-angles are determined as you've probably re-positioned and rotated the camera.
Yea I made it so the crosshair goes with the eye angles it works but it is ultimately useless in gameplay and it makes it hard to aim at someone without the crosshair jittering around.

P.S it shouldn't be hard!
I should be able to just put some offsets in to center it right in the middle of the screen!

Last edited by FeareD: 03-27-2009 at 06:13 PM.
  Reply With Quote
Old 03-27-2009, 06:15 PM   #6
z33ky
 
Join Date: May 2008
Reputation: 169
Posts: 5,361
Did you align it with the eyeangles or really shot a traceline? Because the fix (or whatever you wanna call it) on VALVe's wiki suggests using a traceline.
z33ky is offline   Reply With Quote
Old 03-27-2009, 06:24 PM   #7
FeareD
 
Guest
Posts: n/a
Quote:
Originally Posted by z33ky View Post
Did you align it with the eyeangles or really shot a traceline? Because the fix (or whatever you wanna call it) on VALVe's wiki suggests using a traceline.
EyeAngles.

Hmmm where on the wiki?
Can you link me?
  Reply With Quote
Old 03-27-2009, 06:33 PM   #8
z33ky
 
Join Date: May 2008
Reputation: 169
Posts: 5,361
Sure. Here.
z33ky is offline   Reply With Quote
Old 03-27-2009, 06:38 PM   #9
FeareD
 
Guest
Posts: n/a
Quote:
Originally Posted by z33ky View Post
Sure. Here.
Yea I have done that but the only thing is that it results in the crosshair jumbling around and not staying put, it makes it hard to actually shoot and kill people, especially headshots.

Anyways to stabilize that?
  Reply With Quote
Old 03-27-2009, 07:16 PM   #10
z33ky
 
Join Date: May 2008
Reputation: 169
Posts: 5,361
You could store the old crosshair-position and interpolate like this (always only adding a maximum-clamped value), but of course the aim would be a bit delayed; so depending on how well this would work you have to do some trig in the shooting-angle.
z33ky is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 04:01 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.