Andy Gilbert Posted March 4, 2013 Share Posted March 4, 2013 If i parent an object to the camera entity the object dissapears, im not sure where too, i assume it becomes invisible. Why is this? Thanks Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
YouGroove Posted March 4, 2013 Share Posted March 4, 2013 The object perhaps move to camera position ? I don't know what means parent ? Have you some code to show ? How did you created the camera ? by code or in the editor ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Andy Gilbert Posted March 4, 2013 Author Share Posted March 4, 2013 Hi Yougroove, to parent an object you are telling it to inherit properties of another object: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetparent-r187 What im saying is that when i parent an object to the camera it dissapears. Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
cassius Posted March 4, 2013 Share Posted March 4, 2013 can you move the object forward? 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...
Andy Gilbert Posted March 4, 2013 Author Share Posted March 4, 2013 Ok so this is the code, this script i attatch to an object and drag the camera entity into the target. Script.target = nil--Entity "camera" local tposition = Vec3() function Script:Start() tposition = self.target:GetPosition() tposition = Vec3(tposition.x,tposition.y,tposition.z) self.entity:SetParent(self.target) end The object dissapears, ive tried offseting it from the camera but no show. If i set the target to another object in the editor it works fine. Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
YouGroove Posted March 4, 2013 Share Posted March 4, 2013 Did you frag camera on target slot ? Could you verify in debugger if target is not null ? Or make the test : if self.target not null do stuff else return For a camera system do as i made, without Parent, and use direclty model and camera positions. http://www.leadwerks.com/werkspace/topic/6059-le-3-little-code-examples/ Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Andy Gilbert Posted March 4, 2013 Author Share Posted March 4, 2013 Yes i dragged it in and yes an earlier version did check for null, but still no luck. Doing your way wouldnt work for what im doing, the correct way would be to parent against the camera entity, like in le2. And im sure it should work, but not doing. Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
Josh Posted March 4, 2013 Share Posted March 4, 2013 Can you post your project? I can't tell what the position of the entity and camera are so there's no way to know what's going on. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Andy Gilbert Posted March 4, 2013 Author Share Posted March 4, 2013 Yes i should be able to, but the camera is one created in the editor, along with the object im trying to parent to it. I then assign the above script to the object and drag the camera object into the target. Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 4, 2013 Share Posted March 4, 2013 Ok so this is the code, this script i attatch to an object and drag the camera entity into the target. Script.target = nil--Entity "camera" local tposition = Vec3() function Script:Start() tposition = self.target:GetPosition() tposition = Vec3(tposition.x,tposition.y,tposition.z) self.entity:SetParent(self.target) end The object dissapears, ive tried offseting it from the camera but no show. If i set the target to another object in the editor it works fine. Andy So I tested out your script by attaching it to a box in Darkness Awaits, I then put the camera in the entity field. When I ran the game the box seemed to move how you would expect it to when parented to the camera. If I had to take a random guess I'd say that the object that you are setting as a child of the camera is being moved off screen or behind the camera. I'd check their positions real quick (throw this in after the call to set parent and then check the Output box after running the game: System:Print("camera / tposition: " .. tposition:ToString().." object position: "..self.entity:GetPosition():ToString()) Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 5, 2013 Share Posted March 5, 2013 So the function don't work correctly and we should avoid use it ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Chris Vossen Posted March 5, 2013 Share Posted March 5, 2013 So the function don't work correctly and we should avoid use it ? As far as I know the function is working properly. If it's not let me know! Quote Link to comment Share on other sites More sharing options...
Andy Gilbert Posted March 5, 2013 Author Share Posted March 5, 2013 It is, was my code in the end! Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
YouGroove Posted March 5, 2013 Share Posted March 5, 2013 So what is the code solution with that function to work well ? I'm confused ? Quote Stop toying and make games 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.