Jump to content

How to "speak" with models from the Editor?


DudeAwesome
 Share

Recommended Posts

When I create models in Code it will be something like:

 

cube = new Cube(3)

 

it will create for e.g. a cube with n=3 and I can use cube.setSomething() to use a private function of the Object Cube()

 

 

but how I can access models (like a door) that Ive created in the editor?

 

 

its a little bit confusing. when I create something in the editor, I have no code from it.

 

When I create a cube with some lines of code. I see it in the GameRun but not in the Editor.

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

Link to comment
Share on other sites

but how I can access models (like a door) that Ive created in the editor?

 

This depends on how you want to code things. Do you like doing everything in an int main() type function or are you ok with not seeing an int main()? You can attach a script to an object in the editor and now imagine that's the class for that object. Inside you have a constructor (Start()) and an Update (UpdateWorld()). If it needs access to other objects you can have it take parameters and you can drag and drop the objects from the editor to fill in those parameters (you can even do that in code).

 

If you are an int main() guy, the entity script style can be a little different, but if you approach it with the mindset of the script is a class that runs for that entity you attached it too, then it's not so different. It removes the plumbing code that we would have to do normally.

 

If you create something in code, normally in this script style you'd be creating prefabs, you can fill in it's script parameters in code too. This is what I did with a spawner script. I will be making a tutorial on how to do a spawner script this week and you can see.

  • Upvote 1
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...