Announcement

Collapse
No announcement yet.

How to get actor / components from class

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

    How to get actor / components from class

    Hi helpful guys,

    I want to spawn a specific class (weapons) according to selection of integer. I have tried to select ( class), and get from array (class).

    Im unable to get actor components/ variables of return nod of spawn actor when I connect.

    if i select a class directly it is ok and works fine.

    thanks in advance

    #2
    Seeplus I'm a little confused about you BP. The array on the left is apparently just passing the class type, you might as well just choose it from the drop down on the node.

    What happens when you try to connect the pin you get from the spawn to the 'set weapon direction'?

    You need to differentiate between the 'class' which is just the 'concept', and 'instance', which is an actual example of that class ( ie, a real one ).

    So the spawn node takes a class ( which can just choose, you don't have to pass it from an array unless you're intending on spawning lots of different sorts of things ), and gives you a pointer to an actual instance of that class. Which you can then do stuff with...
    Last edited by ClockworkOcean; 04-05-2019, 09:42 AM.
    Check out Zof ( puzzle game ) on Steam:

    https://store.steampowered.com/app/1414480/Zof/

    Comment


      #3
      Originally posted by ClockworkOcean View Post
      Seeplus I'm a little confused about you BP. The array on the left is apparently just passing the class type, you might as well just choose it from the drop down on the node.

      What happens when you try to connect the pin you get from the spawn to the 'set weapon direction'?


      ..
      The variable “weapon direction” is shared in three actors (weapons) and the projectile component as well. I can get access to them only when i select a class from the menu.

      i decided to get the class from an array to make things clean and simple.

      It wont let me to connec the return node to “ weaon diretion”

      Comment


        #4
        It may be because the BP doesn't know what class it will get until runtime because it needs to evaluate the array. Maybe try casting the Spawn Actor output to your weapon base class and then try connecting the inputs from that.

        Comment


          #5
          Originally posted by DsyD View Post
          It may be because the BP doesn't know what class it will get until runtime because it needs to evaluate the array. Maybe try casting the Spawn Actor output to your weapon base class and then try connecting the inputs from that.
          You are the one today. It works as it was a casting issue. I’ve casted it to the parent weapon class as others are child instances.
          thanks alot

          Comment

          Working...
          X