cassius Posted May 9, 2014 Share Posted May 9, 2014 My character walks straight thru this door. Am I missing something? void setup_door() { door.pivot = Pivot::Create(); door.pivot->SetCollisionType(Collision::Prop); door.pivot->SetPosition(-239.9,9.46,316.03); door.model->SetPosition(door.pivot->GetPosition()); door.pivot->SetMass(0.0); } EDIT: The door is in closed position 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...
Einlander Posted May 9, 2014 Share Posted May 9, 2014 If the door is a model, does the door have a phy file, or does it have a shape? That's the first thing I would think of. Another question is, is the door a child of another object (do you have to click + to get to it)? Quote Link to comment Share on other sites More sharing options...
cassius Posted May 9, 2014 Author Share Posted May 9, 2014 The door is placed in position with the code, not in the editor. 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...
Rick Posted May 9, 2014 Share Posted May 9, 2014 What is door->model? A 3D model I assume? Does it have a physics shape attached to it? With external models you have to assign a physics shape to it yourself (or csg). Probably best to make a prefab of the door where you give it a shape or attach csg with a script attached to it so the csg won't get collapsed. Quote Link to comment Share on other sites More sharing options...
cassius Posted May 9, 2014 Author Share Posted May 9, 2014 Can I assign a shape in code? 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 May 9, 2014 Author Share Posted May 9, 2014 Does this look ok. door.model->SetPosition(-239.9, 9.46, 316.03); Shape* doorshape = Shape::Box(); door.model->SetShape(doorshape); door.model->SetCollisionType(Collision::Prop); door.model->SetMass(0.0); doorshape->Release(); 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...
Einlander Posted May 9, 2014 Share Posted May 9, 2014 You now need to scale the box, or create the box to the same dimensions of your door otherwise, they might slide past it. Quote Link to comment Share on other sites More sharing options...
cassius Posted May 9, 2014 Author Share Posted May 9, 2014 Yeah I was considering that. It works ok as it is, but I may try placing it in the editor and use its classname as reference. Thanks for help. 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...
YouGroove Posted May 10, 2014 Share Posted May 10, 2014 @Cassius : door.pivot->SetCollisionType(Collision::Prop); A pivot is an empty object, it don't need collisions. Why not creating all in the editor instead coding ? I mean place a door model and physics, place the pivot as child object of door, than use simple code , for example : door.FindChild("pivotDoor") The advantage is that visually you can see and adjust your pivot of your door, and save door with script and child pivot as a re usable prefab. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Einlander Posted May 10, 2014 Share Posted May 10, 2014 Yougroove he is using c++ so I would assume that he has a door class that has a pivot member and a model member. Even in lua you can create a pseudo class and create a door without the joint feature. It's a method of containing everything that is related to the door in one compact self contained package. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted May 10, 2014 Share Posted May 10, 2014 I meaned , it could have pivot child and door in the editor and save them as prefab, than re use them in the editor by duplicating them. -Design, physics, pivot placement in the editor and save as prefab -Find prefab instance in C++ and use FindChild (pivot child in the prefab object) in C++ Just another way of working. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
cassius Posted May 10, 2014 Author Share Posted May 10, 2014 The idea in my game is this: Main character walks into room. Enemy closes door from outside locking main character in rom. The door is open and then closes.After that it is never opened again.A sliding door might be easier but I will try normal door first using code. II don;t think I need pivot. 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.