Hi guys.
So what i want to ask is how can i do a slide collision based on a sphere with different x,y,x sizes.
I have a space ship model whose size in x,z is 15 and y=4. I need to keep the y collision at 6 and still have collision with x and z 15.
So its like a nice snug fit collision.
Any ideas?
BTW my level is made out of blocks so the sides of the blocks stops the ship as the ship is on the block it self.
My function has some global values that are vx,vy,vz and a few more.
Heres the function:
void updateplayer()
{
float x,y,z,nx,ny,nz;
dbPositionMouse(125,125);
char text[200];
x=dbObjectPositionX(obj);
y=dbObjectPositionY(obj);
z=dbObjectPositionZ(obj);
vx=vx+(0-vx)/weight;
vz=vz+(0-vz)/weight;
ay=dbWrapValue(ay+dbMouseMoveX()/4);
dbYRotateObject(obj,ay);
if(dbKeyState(17)==1)
{
vx=vx+dbNewXValue(0,ay,speed);
vz=vz+dbNewZValue(0,ay,speed);
}
if(dbKeyState(31)==1)
{
vx=dbNewXValue(vx,ay,-speed);
vz=dbNewZValue(vz,ay,-speed);
}
if(dbKeyState(30)==1)
{
ay=ay-90;
vx=dbNewXValue(vx,ay,speed);
vz=dbNewZValue(vz,ay,speed);
ay=ay+90;
}
if(dbKeyState(32)==1)
{
ay=ay+90;
vx=dbNewXValue(vx,ay,speed);
vz=dbNewZValue(vz,ay,speed);
ay=ay-90;
}
if(dbKeyState(17)==1 || dbKeyState(30)==1 || dbKeyState(31)==1 || dbKeyState(32)==1)
{
vx=vx/1.3;
vz=vz/1.3;
}
vy=-0.7;
if(dbSpaceKey()==1)
vy=0.8;
if(SC_IntersectObject(0,x,y,z,x,y-200,z)>0 && SC_IntersectObject(0,x,y,z,x,y-200,z)<5)
vy=vy+(5-SC_IntersectObject(0,x,y,z,x,y-200,z));
/*x=x+vx;
y=y+vy;
z=z+vz;*/
nx=x+vx;
ny=y+vy;
nz=z+vz;
if(SC_ObjectCollision(obj,0)>0)
{
x=nx-((nx-x)*1.3);
y=ny-((ny-y)*1.3);
z=nz-((nz-z)*1.3);
/*x=nx+x;
z=nz+z;*/
}
else
{
x=x+vx;
y=y+vy;
z=z+vz;
}
/*if(SC_SphereSlide(0,x-vx,y-vy,z-vz,nx,ny,nz,3.4,0)>0)
{
nx=(SC_GetCollisionSlideX()-x)/1.5;
nz=(SC_GetCollisionSlideZ()-z)/1.5;
x=nx+x;
z=nz+z;
}*/
dbPositionObject(obj,x,y,z);
nx=dbNewXValue(x,ay,-35);
nz=dbNewZValue(z,ay,-35);
nx=dbCameraPositionX(obj)+(nx-dbCameraPositionX(obj))/5;
ny=15+dbCameraPositionY(obj)+(ny-dbCameraPositionY(obj))/5;
nz=dbCameraPositionZ(obj)+(nz-dbCameraPositionZ(obj))/5;
if(ny>(dbObjectPositionY(obj)+20))
ny=dbObjectPositionY(obj)+19;
if(ny<(dbObjectPositionY(obj)-10))
ny=dbObjectPositionY(obj)-9;
sprintf_s(text,200,"vx= %f",vx);
dbText(0,0,text);
sprintf_s(text,200,"vz= %f",vz);
dbText(0,10,text);
sprintf_s(text,200,"ay= %f",ay);
dbText(0,20,text);
dbPositionCamera(obj,nx,ny,nz);
dbPointCamera(obj,x,y+15,z);
SC_UpdateObject(obj);
}
Your signature has been erased by a mod