Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 16874

Calc sliding vector...

$
0
0

So i began to write collision again, in order to calculate new velocity vector after collision i want to project a vel vector onto plane to get new velocity direction (and length) however i get something else (almost the same direction as initial vel vector but X times bigger length)

So after calcing collision point and collision normal i do:

		pp->pos = nearest_col.new_pos;
		vec3 slide_n = nearest_col.col_normal;

		float slide_d = -dot(slide_n, nearest_col.col_point);
		
		vec3 vprojected = ProjectVectorOnPlane(slide_n, slide_d, pp->vel);
		pp->vel = vprojected;
template <class type> t3dpoint<type>  ProjectVectorOnPlane(
t3dpoint<type> n, type d, t3dpoint<type> v)
{
float signed_dst = dot(n, v) + d;
	
return v …

Viewing all articles
Browse latest Browse all 16874

Trending Articles