Announcement

Collapse
No announcement yet.

What is more proper to use? (component or actor or uobject)

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

    What is more proper to use? (component or actor or uobject)

    I have a SpellCasterComponent which is owned by a Controller.

    Within this component I want to add another object to handle the SpellBook (which is a container of spells with some functions to load, add, delete, etc.. that will need to be replicated).

    What the SpellBook should be? a Component? an UObject? an Actor?

    It is nothing more than a Container of spells, so I would choose UObject but maybe an Actor is required in order to replicate on the server.

    #2
    If you want the spell book to be replicated, then you can't really use a UObject unless you're happy to replicate its variable through an AActor. You could make an UActorComponent and then replicate it through the owning AActor. UActorComponent or UObject will be more light weight than an AActor however.

    Comment


      #3
      On the other hand, if spellbook is a list of spells and this list doesn't change, then you don't need to replicate it. It could be a simple UObject that will have the same content on server and all clients, and reference to a spell will resolve to the same one, you could replicate this reference. (eg spellId, that is accessed via Spellbook->GetSpellById(spellId))
      • Follow me on twitter
      • Visit our website traverse.world
      • Checkout our game's forum thread

      Comment


        #4
        That's definitely a great idea! You'd have to be a little careful about creation of the spells though I think.

        Comment


          #5
          Originally posted by xulture View Post
          On the other hand, if spellbook is a list of spells and this list doesn't change, then you don't need to replicate it. It could be a simple UObject that will have the same content on server and all clients, and reference to a spell will resolve to the same one, you could replicate this reference. (eg spellId, that is accessed via Spellbook->GetSpellById(spellId))
          Problem is that spells can be crafted so I can't really have an unique identifier for each spell.

          For the moment I made the Spellbook an Actor, and spawn it in SpellCasterComponent BeginPlay method,
          but this is bothering me since the more appropiate place to spawn it should be in the constructor but I can't spawn actors within a constructor (World is null)

          Comment


            #6
            Originally posted by MaxiHori View Post
            Problem is that spells can be crafted so I can't really have an unique identifier for each spell.

            For the moment I made the Spellbook an Actor, and spawn it in SpellCasterComponent BeginPlay method,
            but this is bothering me since the more appropiate place to spawn it should be in the constructor but I can't spawn actors within a constructor (World is null)
            If you need it to be actor, there is no problem spawning it in BeginPlay (or even inside Tick, when it's needed, if it is not spawned already).

            You could change it into Component, so you can create it in constructor.

            There is no real 'correct' way of doing it; it all depends how you need it. Actors can have their components. Components can't, but both actors and components can have their own replication rules. Raw UObjects can only be replicated via its parent (component or actor). All approaches are ready to be used whichever way suits!
            • Follow me on twitter
            • Visit our website traverse.world
            • Checkout our game's forum thread

            Comment


              #7
              Originally posted by xulture View Post
              Actors can have their components. Components can't
              what do you mean? I can't have a component attached to another component?

              Comment


                #8
                Originally posted by MaxiHori View Post
                what do you mean? I can't have a component attached to another component?
                I think that this information is held by the owning actor (sub-attachment of components to each other); but I'm not 100% sure.

                Eg, in Actor's constructor (that owns both components), you'd attach one component to another via
                Code:
                FollowCamera->AttachTo(CameraBoom)
                • Follow me on twitter
                • Visit our website traverse.world
                • Checkout our game's forum thread

                Comment


                  #9
                  This is totally unclear to me -.-

                  Still I think I'm gonna stay with simple Actor, it seems that it would be the less problematic choice.

                  Comment

                  Working...
                  X