Jump to content

Recommended Posts

Posted

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

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

Posted

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 ?

Stop toying and make games

Posted

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

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

Posted

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

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

Posted

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

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

Posted

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.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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

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

Posted

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.

 

post-5181-0-17693800-1362438689_thumb.png

 

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())

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.

×
×
  • Create New...