Rick Posted December 16, 2009 Share Posted December 16, 2009 Trying to figure out why this crashes on me when I go out of game mode. It has to do with the Kill() event. If I comment out the code in the Kill() event it works fine, BUT then I get multiple cubes being created every time I run the game. function Spawn(model) local entity=base_Spawn(model) entity.model=model entity.cameraPivot = CreatePivot() entity.playerPivot = CreatePivot() entity.playerPivotCube = CreateCube() -- make the player pivot the camera pivots parent so it moves with the player pivot EntityParent(entity.cameraPivot, entity.playerPivot) return entity end function Kill(model) local entity=base_Spawn(model) FreeEntity(entity.playerPivotCube) end Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 16, 2009 Share Posted December 16, 2009 why are you doing the Spawn in the Kill function? should be local entity=base_Kill(model) Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Niosop Posted December 16, 2009 Share Posted December 16, 2009 Why are you running spawn in your Kill? You should call base_Kill(model) but call it AFTER you do your other stuff. As an alternative, you could do: function Kill(model) entity.playerPivotCube:SetParent(model) base_Kill(model) end This should cause the playerPivotCube to get destroyed along with it's parent. I haven't tested this though, so it could result in bad things like your dog getting sick on your carpet or something. Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Rick Posted December 16, 2009 Author Share Posted December 16, 2009 didn't even notice that. that is what copy/paste will get ya. thanks! Quote Link to comment Share on other sites More sharing options...
Flexman Posted December 16, 2009 Share Posted December 16, 2009 Yes, to confirm, any children will also be destroyed it when base_Kill iterates through the model. *gulp* Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
Rick Posted December 16, 2009 Author Share Posted December 16, 2009 Still having some issues here. I only want to free the cube and the pivots created in the spawn. I look at the monster truck for an example but when I kind of do the same thing it errors. function Kill(model) local entity entity=entitytable[model] FreeEntity(entity.playerPivotCube) FreeEntity(entity.playerPivot) FreeEntity(entity.cameraPivot) end It says local entity is a nil value Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 16, 2009 Share Posted December 16, 2009 look at how the lights are done: function Kill(model) local entity=entitytable[model] if entity~=nil then if entity.light~=nil then entity.light:Free() entity.light=nil end end base_Kill(model) end Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted December 16, 2009 Author Share Posted December 16, 2009 Cool that worked. I thinking not setting it to nil was causing the crash. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.