Jump to content

[Linux, Beta] Entities that are meshes/models that get passed via script parameters seem broken.


DerRidda
 Share

Recommended Posts

So, I set up a nice RTS style camera control script. The script receives its camera through a script parameter and that camera gets moved around by WASD and the scrollwheel which all works nice.

 

Now I'm trying to move another entity passed via script parameters to the spot where I clicked (via camera picking naturally) and I've found out that it simply crashes the game process without comment whenever that entity is a model. Every other entity type I have tried works or throws its proper error message (like Directional Lights complaining about SetPosition being a nil value).

 

It works when I create a model inside the script or when I attach it to another entity type that works (via the hinge script for example).

 

After further investigation I have found out that basically anything I try to actively do to a model that was passed via scrip parameters simply crashes the game app. Like scaling or changing color.

 

Unless I missed a pretty esoteric way in which model entities need to be treated differently just for this situation I'm pretty sure this is a bug.

Link to comment
Share on other sites

Yeah, I was really trying to figure out what I did wrong there but I'm clueless.

 

There isn't much happening yet. Toss this script into a new map, create terrain, use a camera that's angled towards the ground and add your testing model.

 

Script.testentity = "" --entity "Click Tester"
Script.camera = "" --entity "Target Camera"


function Script:Start()
mwheelstart = 0
clickpick = PickInfo()
textpos = Vec2(0,0)
wtf = self.testentity
--wtf = Model:Box()
   --wtf:SetColor(0.0,0.0,1.0)
end



function Script:UpdateWorld()

--Handle camera movement
transcam = Vec3(0,0,0)
movecam = Vec3(0,0,0)
if App.window:KeyDown(Key.A) then transcam.x = -1 elseif App.window:KeyDown(Key.D) then transcam.x = 1 end
if App.window:KeyDown(Key.W) then transcam.z = 1 elseif App.window:KeyDown(Key.S) then transcam.z =- 1 end
self.camera:Translate(transcam, true)
if App.window:GetMousePosition().z > mwheelstart then movecam.z = 1 elseif App.window:GetMousePosition().z < mwheelstart then movecam.z = -1 end
mwheelstart = App.window:GetMousePosition().z
self.camera:Move(movecam*3)

--handle clicky stuff
if App.window:MouseHit(1) then 
self.camera:Pick(App.window:GetMousePosition().x, App.window:GetMousePosition().y, clickpick, 0, true)
wtf:SetPosition(clickpick.position, true)
end

end

Link to comment
Share on other sites

Yeah seems to work for me on Win 8. What model are you using? I used the default barrel.mdl that comes with new projects. Have you tried that to see if it works? Just curious as the only other thing I can think of is the model you are using (besides you using Linux but trying to eliminate everything else first).

 

My steps:

 

1) Create new project (beta branch)

2) Add terrain

3) Add directional light

4) Add camera

5) Create a new script I named Test.lua and copy/pasted your script above

6) Add pivot and attach Test.lua

7) Add barrel to map

8) Drag camera over Target Camera parameter and drag barrel over Click Tester parameter on script

Link to comment
Share on other sites

This whole thing confuses me even more. I only used primitives created via Leadwerks before, spheres and boxes, those cause the issue.

Using .mdl files from the asset browser seems fine.

 

Another strange thing: If I give these primitives a collision shape so that they become physics objects they work while .mdl entities flawlessly work without a collision shape. Mass seem irrelevant, so does collision type.

 

Just did another test, I know what this is now, might be a considered user error but I really didn't expect this.

I attached an empty script to the model and now it works.

 

I guess the meshes still got collapsed into world geometry. This was a user error but also kinda unexpected, I set their collision types to prop (while not giving them mass or a shape) and expected that would prevent this from happening. I thought this was limited to scene collision. Guess not.

Link to comment
Share on other sites

So csg/primitives get collapsed and aren't treated like normal models UNLESS they have mass OR they have a script attached to them.

 

This is a gotcha and people have asked for a flag in the editor per item that would prevent the collapse when checked. Josh has said he thinks it's a good idea, but hasn't implemented it yet.

  • Upvote 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...