x


Is every Script I drag on a Gameobject an instance?

Hey,

When you usually program in C#, you can make a class

public class myClass : typeOfClass { }

What I dont understand (I also checked this site) is:

Is every Gameobject which I put my Script on an instance of the class that is defined in the script?

Im sure it is like this, but I really would like to also hear it from someone else =)

more ▼

asked Jul 17 '12 at 08:06 PM

bridged gravatar image

bridged
13 4 10 11

The way I see it, which could be totally wrong though, a game object has a whole bunch of inherited classes (Object, Behaviour,Vector3, Collision,...) and when you add a script you add a new class to it with its own variables and functions.Difference is the other objects do not inherit it. This is my simplified vision, obviously it is a little more than that.

Jul 17 '12 at 08:20 PM fafase
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Each component on a GameObject represents an instance of that component type. So, yes.

This can lead to complications if you need some way to tell them apart, but there's usually some way to manage it.

more ▼

answered Jul 17 '12 at 08:08 PM

rutter gravatar image

rutter
5.2k 2 11

allright, that's what I wanted to hear and the same thing u just said about telling them apart is one thing that was confusing me because you do not really name them. But from the aspect that they ARE instances I can imagine that they and how they are differenced.

Jul 17 '12 at 10:54 PM bridged
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3331
x2088
x337
x204

asked: Jul 17 '12 at 08:06 PM

Seen: 302 times

Last Updated: Jul 17 '12 at 10:54 PM