Announcement

Collapse
No announcement yet.

Spawn Function not global?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Spawn Function not global?

    In my function ButtonClick which is part of my class extending GuiTabPanel, I define:

    Code:
    function bool ButtonClick(GUIComponent Sender)
    {
    local actor myactor;
    myActor = spawn(class'SkaarjPack.Manta',vect(100,100,100),rot(0,0,0));
    }
    which brings up a compile error.

    If I define:

    Code:
    function bool ButtonClick(GUIComponent Sender)
    {
    local actor myactor;
    myActor = PlayerOwner().spawn(class'SkaarjPack.Manta',vect(100,100,100),rot(0,0,0));
    }
    it compiles without any problems.

    Why do I need a Object of Playercontroller in order to spawn a new object? Is spawn not some defined to create new objects without any references?

    OOP is totally new and maybe 20 years programming "normal" languages messed me up for oop , but I have somehow problems getting this into my brain.

    Thanks for any help,
    Andreas

    #2
    Spawn is declared in Actor.uc, so you can access it only from a subclass of Actor.

    Comment


      #3
      Thanks

      Thanks, clear now...

      can the function "spawn" spawn only object from class actor or its subclasses ?

      If no - why did they put it there and not in class object?
      If yes - I cannot make a class meal extending object and spawn pizza like the wiki example did ... I *must* extend actor ? Correct?

      TIA
      Andreas

      Comment


        #4
        You can only spawn actors, yes. To create an instance of an object class you need to use 'new' instead. That should be explained on the Wiki somewhere. It's done like that because actors require some extra setting up that objects don't.

        Comment

        Working...
        X