Jump to content

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.

Link to comment
Share on other sites

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

Stop toying and make games

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

@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 ?

  • Upvote 1

Stop toying and make games

Link to comment
Share on other sites

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

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 4 years later...
  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...