Jump to content

Using Camera::Pick to make a model do stuff.


RygtY
 Share

Recommended Posts

Hi I went through the Object script tutorials and I've gotten that crate model to rotate.

 

I've also tested out the Pick example for the Camera class.

 

Now my question how do I make a Camera object that I placed in the editor to do a "Pick" on the crate model then have that model rotate (and maybe even play a sound)?

Link to comment
Share on other sites

Inspired from FPSPlayer.lua

 


function Script:UpdateWorld()

...

if window:KeyHit(Key.E) then

local p0 = self.camera:GetPosition(true)
local p1 = Transform:Point(0,0,self.useDistance,self.camera,nil)
if self.entity.world:Pick(p0,p1, pickInfo, 0, true) then
		 if self.entity:GetType() = "crate" then
				 self.entity:SetOmega(10,10,10)
		 end
	 end
end
...

end

 

For sound commands you cna dig AI ro FPSPlayer lua scripts.

Stop toying and make games

Link to comment
Share on other sites

So where should I attach such a script?

 

Also how do I make a script that can reference the camera I've placed using the editor than in a script file? I need some help in reconciling the two possible ways to make a camera in the engine either by scripting it or using the editor.

Link to comment
Share on other sites

The script above like you can see is on the UpdateWorld().

 

Inside your script just declare an empty entity :

Script.myCamera = nil -- entity

 

The word "--entity" will make some empty field in the script panel where you can drag and drop the camera.

To use it in your functions just use it like that :

self.myCamera:SetPosition(0,0,0,false)

 

You would recommend you to ask Rick for some learning course on Lua and LE3 as he gives courses for beginners.

Stop toying and make games

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