Jump to content
Rick

Entity script parameters don't seem to work anymore

Recommended Posts

Script.MyEntity = nil --entity "MyEntity"

 

 

Then I fill this in via the editor by dragging and dropping an entity to this parameter. It doesn't seem like the engine is filling this in anymore as the value stays nil which causes the program to bomb.

 

This is in the beta branch.

Share this post


Link to post

I'm in Beta, just tested and no problem, what i put in the field remains and works in the code.

 

Script.cam = nil --entity
function Script:Start()
local pos = self.cam:GetPosition(true)
self.entity:SetPosition(pos,true)
end

Share this post


Link to post

Try doing that in UpdateWorld() because it works for me when it's accessed in Start() too, but errors when inside UpdateWorld()

Share this post


Link to post

Let's see your script. I bet you forgot "self.".

Share this post


Link to post

Negative batman. Take YouGrooves script above and put the code that he has in Start() in UpdateWorld() and it blows up. It works in Start() though. A straight up copy/paste of local pos = self.cam:GetPosition(true) causes the blow up in UpdateWorld() but works in Start()

 

 

 

Script.cam = nil --entity

function Script:Start()

local pos = self.cam:GetPosition(true)

self.entity:SetPosition(pos,true)

end

Share this post


Link to post

Had a quick test and this works, my box jumps up and down when player does.

 

Attach this to a box and drag and drop player to the script variable

 

Script.playerentity= ""--entity

function Script:Start()

end


function Script:UpdateWorld()
   local y = self.playerentity:GetPosition().y
   local pos = self.entity:GetPosition()
   pos.y = y
   self.entity:SetPosition(pos)
end

Share this post


Link to post

Bah, this was the csg getting collapsed issue. My entity was a csg. Put a dummy script on it then it worked. Where is our checkbox for csg to not collapse smile.png

 

Although I'll have to dbl check because if my training session this morning we passed a camera entity and it wasn't working, which isn't csg and wouldn't get collapsed.

 

hmm I swear I double checked everything this morning and it didn't work. >< I guess you can close.

Share this post


Link to post

@Rick :

New code

Script.cam = nil --entity

function Script:Start()
--local pos = self.cam:GetPosition(true)
--self.entity:SetPosition(pos,true)
end

function Script:UpdateWorld()
local pos = self.cam:GetPosition(true)
self.entity:SetPosition(pos,true)
end

 

It's some one time bug , i got your problem like you first time only. But trying again and putting again camera on script field it worked now, i made several other tests with same script no more problem.

Could you try again dropping entity on script slot ?

Share this post


Link to post

Yeah, I know I'm not going crazy here. There must be some special situation where the engine isn't setting the param.

Share this post


Link to post

I see the visible entity disappearing when a prefab is used for the scripted entity.

 

Ah, no it is a hierarchy thing. If you have multiple entities selected, it just appears blank. I should make that say <different>.

 

However, this does not seem to effect actual behavior in the game as you describe,.

Share this post


Link to post

I'm going to file this one away unless there is still an issue here...

Share this post


Link to post
Guest
This topic is now closed to further replies.
×
×
  • Create New...