Jump to content

Parent camera issue?


Andy Gilbert
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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/

Stop toying and make games

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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...