Jump to content

c++ problem


cassius
 Share

Recommended Posts

THe code below stops the camera getting hidden behind walls in a 3rd person game.Its from an aggror c++ tutorial and works fine with walls. The problem comes in hilly terrain where it thinks a hill is a wall and makes my character disappear and re appear all the time.

Anyoe help???

EDIT thegame is ok without this code. but I just wondered.

 

 

 

 

 

 

 

 

PickInfo pick;

if (world->Pick(fpsPivot->GetPosition(), tpsPivot->GetPosition(), pick, 0, true))

{

//Store distance

float distance = fpsPivot->GetPosition().DistanceToPoint(pick.position);

printf((String(distance) + "\n").c_str());

 

//If the tps distance is to small, we switch to FPS view

if (distance < minCamOffset)

{

camera->SetPosition(fpsPivot->GetPosition());

}

else

{

camera->SetPosition(pick.position);

}

}

else

{

camera->SetPosition(tpsPivot->GetPosition());

/

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

The collision type ("collisiontype") in the Pick function is the 7th parameter. The default is set to pick all objects. You would set the "collisiontype" parameter to something that does not pick the terrain.

 

bool Pick(const Vec3& p0, const Vec3& p1, Pick& pick, float radius = 0.0, bool closest=false, bool recursive=false, int collisiontype=0)

 

http://www.leadwerks.com/werkspace/page/api-reference/_/command-reference/collision-r778

 

Unfortunately, I am not sure what collision type is set for terrain as I have not worked with terrain much.

Play Our Latest Game: Relic Rogue

Link to comment
Share on other sites

You set the pick's collision as Collision.LineOfSight which according to this diagram will only collide with 'Collision.Scene' collision types.

 

Here is the list of the inherent collision types and responses:

List of inherent types:

Collision.Prop = 1

Collision.Scene = 2

Collision.Character = 3

Collision.Trigger = 4

Collision.Debris = 5

Collision.Projectile = 6

Collision.LineOfSight = 7

 

List of possible responses:

Collision.None = 0

Collision.Collide = 1

Collision.Trigger = 4

 

With the following warning from Josh concerning using the constants and not the numerical values: "You really should stick to using the named constants. Technically, the values of these are allowed to change at any time, without breaking the spec."

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...