cassius Posted January 26, 2016 Share Posted January 26, 2016 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()); / Quote 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 More sharing options...
AggrorJorn Posted January 31, 2016 Share Posted January 31, 2016 Have you tried specifying a collisiontype so terrain gets ignored? Quote Link to comment Share on other sites More sharing options...
cassius Posted February 1, 2016 Author Share Posted February 1, 2016 no. how do I do that? Quote 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 More sharing options...
T0X1N Posted February 1, 2016 Share Posted February 1, 2016 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. Quote Website | Twitter | Facebook | Steam Play Our Latest Game: Relic Rogue Link to comment Share on other sites More sharing options...
cassius Posted February 1, 2016 Author Share Posted February 1, 2016 I have five parameters. If I add two more I get syntax error. What should that line look like? Thanks. Quote 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 More sharing options...
Brutile Posted February 1, 2016 Share Posted February 1, 2016 World pick is a bit different: Pick(const Vec3& p0, const Vec3& p1, PickInfo& pickinfo, float radius=0.0, bool closest=false, int collisiontype=0) Quote Link to comment Share on other sites More sharing options...
cassius Posted February 1, 2016 Author Share Posted February 1, 2016 not sure what value to put in last parameter. I tried 0 to 4. Choosing 4 worked for hilly terrain but then it could not detect walls either. Quote 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 More sharing options...
Brutile Posted February 1, 2016 Share Posted February 1, 2016 The collisiontype refers to Collision types. So for example, if you use Collision.Scene, it will pick everything except Scene. Collision.Debris will only pick Scene and Prop, etc. Quote Link to comment Share on other sites More sharing options...
cassius Posted February 1, 2016 Author Share Posted February 1, 2016 Thanks everyone for explanations. Quote 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 More sharing options...
cassius Posted February 2, 2016 Author Share Posted February 2, 2016 Got it working with a 7 as the last parameter. Works with any "Scene" object. Still don't know why but that's ok. Quote 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 More sharing options...
macklebee Posted February 3, 2016 Share Posted February 3, 2016 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." Quote 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 More sharing options...
cassius Posted February 3, 2016 Author Share Posted February 3, 2016 I was putting 6, thinking that counting began at 0.In c++ the syntax is " Collision::LineOfSight " it seems. Thanks Mac. Quote 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 More sharing options...
Recommended Posts
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.