Jump to content

LE3 : object in front of camera


YouGroove
 Share

Recommended Posts

Well i use teh script free camera look.

I would need to place in front of camera some object, does anyoen knows how ot program that ?

because we have camera position and rotation already.

 

Tried that : but it don't runs and says SetPosition is not good ?

 

function Script:Render()

self.entity:SetPosition(self.pivot:GetPosition(true),true)

deltaPosx = self.pivot.x

deltaPosy = self.pivot.y

deltaPosz = self.pivot.z

launcher:SetPosition(deltaPosx,deltaPosy,deltaPosz,true)

end

Stop toying and make games

Link to comment
Share on other sites

Nope weapons will have to be dynamic.

 

The camera have "freelook" script, i just added weapons management in it for the moment.

 

The launcher is loaded by code, and declared as globam variable.

 

function Script:Start()

launcher = Model:Load("Models/Characters/test/launcher.mdl")

 

Then it is rotated as camera is rotated

function Script:UpdatePhysics()

...

...

camerarotation.x = camerarotation.x+self.mousespeed.y*self.lookspeed

camerarotation.y = camerarotation.y+self.mousespeed.x*self.lookspeed

self.entity:SetRotation(camerarotation)

launcher:SetRotation(camerarotation)

 

 

 

 

Finally i tried to move it in front of camera : but compilation fails

function Script:Render()

self.entity:SetPosition(self.pivot:GetPosition(true),true)

deltaPosx = self.pivot.x

deltaPosy = self.pivot.y

deltaPosz = self.pivot.z

launcher:SetPosition(deltaPosx,deltaPosx,deltaPosx )

end

 

 

I guess, it's another maths that are needed to place some object in front of camera like using the normal vector of camera direction.

Stop toying and make games

Link to comment
Share on other sites

Well as you can see in my video I have an fps style gun attacted to the camera or self character. I didn't make this global as I have developed a weapon management for the main character only (yourself) so my weapons are completely self controlled. As in I have a script for each weapon as each weapon is different and has many different properties. And these are then attached to the relative weapon model that can be picked up by the main character.

 

I didn't have to use any normals of the camera. Using parenting is the way I do it.

 

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

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