Jump to content

Collider Boxes in the Editor ?


ParaToxic
 Share

Recommended Posts

Hello guys, I'm very bad in lua so I have a question about some collider box stuff.

 

I would like to create a entity which you can place in the editor and create a 3D box with 3 mouse clicks.

When you place it you click on the ground once and from this point a box starts to follow your mouse ( just a 2D square maybe). When you click a second time the box has then a fixed size and you can now control the height of the box with the mouse.When you have your height you click a third time and you have your own, perfect sized collider box.

 

But how I can make that with mouseclicks and soone as a object, you can just place in the Editor ??

Thanks

Link to comment
Share on other sites

Well it is very bad code but it works , for my lua knowledge :D

Yes I could store it as keys, your right

require("scripts/class")
local class=CreateClass(...)

function class:InitDialog(grid)
end

function class:CreateObject(model)
local object = self.super:CreateObject(model)
local object=self.super:CreateObject(model)
SetWorld(fw.transparency.world)
object.cube=CreateCube()
object.cube:SetScale(Vec3(4,4,4))
object.cube:Paint(LoadMaterial("abstract::collider.mat"))
object.axis1 = 0
object.axis2 = 0
object.axis3 = 0
object.scalex = 1
object.scaley = 1
object.scalez = 1
object.setall = 0
SetWorld(fw.main.world)
function object:Update()

self.cube:SetPosition(self.model:GetPosition())
if self.axis1 == 0 and self.axis2 == 0 and self.axis3 == 0 then
self.cube:SetScale(Vec3(self.scalex,self.scaley,MouseX()/100))
if MouseHit(1) == 1 then
self.scalez = MouseX()/100
self.axis2 = 1
self.axis1 = 1
end
end
if self.axis1 == 1 and self.axis2 == 1 and self.axis3 == 0 then
self.cube:SetScale(Vec3(MouseX()/100,self.scaley,self.scalez))
if MouseHit(1) == 1 then
self.scalex = MouseX()/100
self.axis3 = 1
end
end
if self.axis1 == 1 and self.axis2 == 1 and self.axis3 == 1 then
self.cube:SetScale(Vec3(self.scalex,MouseX()/100,self.scalez))
if MouseHit(1) == 1 then
self.scaley = MouseX()/100
self.axis1 = 0
self.userdata = self.cube
end
end
end

function object:Free()
if self.cube~=nil then
self.cube:Free()
self.cube=nil
end
self.super:Free()--Don't forget this!!
end

end

  • Upvote 1
Link to comment
Share on other sites

  • 2 weeks later...

That's cool, do you mind if I use this technique for a setting sizing properties on a trigger system?

Tools:

AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro

 

Programing & Scripting Languages:

C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby

Link to comment
Share on other sites

Something to watch out for, if I'm not mistaken that code will run in game also. When I was doing stuff like this with my Pi scripts, I made a flag that would tell me if I'm in the editor or running the game so I could skip over editor parts when running the game.

Link to comment
Share on other sites

@Rick: Thats a good idea for that.But how can I find out that I'm running it in the editor ?

I saw that LE3 comes with a collisiontrigger script, so I will wait for that :D

Also it should save the properties as keys ( I mean the scale ) and load it from keys when exist, because now when I load a scene I have to resize all the collisionboxes again.

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