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

Reply
 
Thread Tools Display Modes
Old 03-20-2012, 05:07 PM   #1
serrath
 
Join Date: Feb 2012
Reputation: 0
Posts: 37
Question Walls & Collision Detection (How's it work? What's involved?)

I want to grab some info about the player when he collides with a wall and some info about the wall (i.e. its facing, etc). I've been going through the wiki but I can't find what I'm after. Could someone link me to the relevant articles?

Last edited by serrath: 03-20-2012 at 06:59 PM.
serrath is offline  
Reply With Quote
Old 03-20-2012, 10:11 PM   #2
beonard6
 
 
 
Join Date: Aug 2010
Reputation: 7
Posts: 28
Touching walls is similatr to touching ground.
Guess because both wall and ground have flag SOLID_BSP.
Is you're asking about func_wall, well, source code is open for you.
beonard6 is offline   Reply With Quote
Old 03-21-2012, 07:30 AM   #3
serrath
 
Join Date: Feb 2012
Reputation: 0
Posts: 37
It says func_wall is outdated and I should be looking at func_brush instead? Specifically I want to determine the orientation of the plane of a surface the player bumps into. (It'd also be nice if I could tell when the player stops touching the surface.)
serrath is offline   Reply With Quote
Old 03-21-2012, 07:47 AM   #4
beonard6
 
 
 
Join Date: Aug 2010
Reputation: 7
Posts: 28
from gamemovement.cpp:
Code:
// Slide off of the impacting object
// returns the blocked flags:
// 0x01 == floor
// 0x02 == step / wall
int CGameMovement::ClipVelocity( Vector& in, Vector& normal, Vector& out, float overbounce )
{
	float	backoff;
	float	change;
	float angle;
	int		i, blocked;
	
	angle = normal[ 2 ];

	blocked = 0x00;         	// Assume unblocked.
	if (angle > 0)			// If the plane that is blocking us has a positive z component, then assume it's a floor.
		blocked |= 0x01;	// 
	if (!angle)			// If the plane has no Z, it is vertical (wall/step)
		blocked |= 0x02;	// 
	

	// Determine how far along plane to slide based on incoming direction.
	backoff = DotProduct (in, normal) * overbounce;

	for (i=0 ; i<3 ; i++)
	{
		change = normal[i]*backoff;
		out[i] = in[i] - change; 
	}
	
	// iterate once to make sure we aren't still moving through the plane
	float adjust = DotProduct( out, normal );
	if( adjust < 0.0f )
	{
		out -= ( normal * adjust );
//		Msg( "Adjustment = %lf\n", adjust );
	}

	// Return blocking flags.
	return blocked;
}
PS: actually
beonard6 is offline   Reply With Quote
Old 03-21-2012, 07:53 AM   #5
serrath
 
Join Date: Feb 2012
Reputation: 0
Posts: 37
Ah, thank you! I'm trying to implement wall-running; I've got the vector math down, I just didn't know where to find this. Many thanks!
serrath 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 12:06 AM.


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