Jump to content

Recommended Posts

Posted

In my training today we were attempting to change the material on a surface of a model that was loaded in the scene at design time. The model was a child of a csg box which was what was being checked for picking. The problem is that we were able to get the child (the actual model) and call Entity functions on it, but not Model functions, which is how you get surfaces.

 

What am I missing on how to get the surface of a model loaded at design time?

 

 

For example, this works because SetColor() is an Entity function and GetChild() returns an Entity

self.entity:GetChild(0):SetColor()

 

 

This blows up with the function being nil because GetSurface() exists for Models not Entities

self.entity:GetChild(0):GetSurface(2)

 

 

Was looking through the docs and couldn't see any sort of conversion function. Any ideas?

Posted

You might need to cast it first, something like this to get its methods :

 


local model=self.entity:GetChild(0)

tolua.cast(model,"Model")

local surf=model:GetSurface(2)

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

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.

×
×
  • Create New...