Jump to content

[Indie] Prefab Load Problem


DudeAwesome
 Share

Recommended Posts

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?

It doesn´t work... why? mhmmm It works... why?

Link to comment
Share on other sites

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.

It doesn´t work... why? mhmmm It works... why?

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