DudeAwesome Posted January 24, 2014 Share Posted January 24, 2014 Hi guys, I created a Prefab using the Editor (just a cuboid) and want to load them into the scene when a button is pressed. When I drop the prefab into the editor the physics are fine (physics tab -> shape box, mass=1, props) but when I load them into the scene with this Code the Prefab has no shape I guess because its falling through the ground. Is this a Bug or I´m too stupid? Quote It doesn´t work... why? mhmmm It works... why? Link to comment Share on other sites More sharing options...
DudeAwesome Posted January 24, 2014 Author Share Posted January 24, 2014 I dont know why but now it works. but I dont changed something strange ---------edit----------- ok I know when this happens. when I load a prefab and rotate it with SetRotation() the prefab falls through my ground. when I dont SetRotation() its ok. works Script.ItemPath = "" --path "(Prefab) Item" Script.MaxItems = 5 --int "Max Spawn Items" Script.DroppedItems = 0 --Number of Items dropped function Script:DropItem() --in if(self.DroppedItems < self.MaxItems) then self.DroppedItems = self.DroppedItems + 1 System:Print("Drop") self.prefab = Prefab:Load("Prefabs/test.pfb") --SpawnPosition is Pivo Position self.prefab:SetPosition(self.entity:GetPosition().x,self.entity:GetPosition().y,self.entity:GetPosition().z) --Rotate Prefab --self.prefab:SetRotation(0,90,90) --self.prefab:PhysicsSetRotation(0,90,90) else System:Print("maximal items dropped") end end dont works Script.ItemPath = "" --path "(Prefab) Item" Script.MaxItems = 5 --int "Max Spawn Items" Script.DroppedItems = 0 --Number of Items dropped function Script:DropItem() --in if(self.DroppedItems < self.MaxItems) then self.DroppedItems = self.DroppedItems + 1 System:Print("Drop") self.prefab = Prefab:Load("Prefabs/test.pfb") --SpawnPosition is Pivo Position self.prefab:SetPosition(self.entity:GetPosition().x,self.entity:GetPosition().y,self.entity:GetPosition().z) --Rotate Prefab self.prefab:SetRotation(0,90,90) --self.prefab:PhysicsSetRotation(0,90,90) else System:Print("maximal items dropped") end end even when I uncomment the PhysicsSetRotation() Function it wont work. Quote It doesn´t work... why? mhmmm It works... why? Link to comment Share on other sites More sharing options...
YouGroove Posted January 24, 2014 Share Posted January 24, 2014 Loading prefab by code , im' not sure mass and physics are saved/loaded. Perhaps by code set it's mass and shape after loading it. Quote Stop toying and make games 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.