Announcement

Collapse
No announcement yet.

UNREAL UE4 - How to Spawn Actor with an actor class variable without error warnings? image attached

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

    UNREAL UE4 - How to Spawn Actor with an actor class variable without error warnings? image attached

    Hi, i created an struc and data table to use weapons, it also contains the specific "actor class" for each projectile type to be fired, but i canot connect the actor class variable to "spawn actor" nor promote to variable without this error: "Specifying non-default value no longer exists on node spawnactor" and a red new Var 0.

    How can i connect the actor class variable to spawn actor? I already tried to make the variable editable and expose on spawn, also since the newvar0 is in red i tried to add an actor reference to the struct, but it wont show up in the data tables… Here is the BP and errors:

    Click image for larger version  Name:	actor-class.png Views:	1 Size:	77.5 KB ID:	1523140

    Please help
    Last edited by RoccoFX; 09-03-2018, 02:02 AM.

    #2
    If you want to use an arbitrary Actor Class in the SpawnActor node and still be able to set a custom exposed variable on spawn you will need to cast the ActorClass variable to a specific type before being able to set the variable.

    If the variable is on a base class you could also simply convert the Actor Class Reference from an Actor Class to your Base Class to avoid the cast.
    Last edited by GarnerP57; 09-03-2018, 04:27 AM.

    Comment


      #3
      I got same errors when casting with a variable and use this as connection for the actor spawn:

      Click image for larger version  Name:	actor-class1.png Views:	1 Size:	129.4 KB ID:	1523496

      I Will be pressing buttons to change weapon, each weapon must be in a data table, in there i have specified the "actor class" for each weapon (a projectile), for that reason i need to connect a variable to the actor spawn in the BP… it wont be an specific actor defined at the BP, it Will take the actor class from the data table, i already made that process to work… but using a variable to make the class its not working.

      Casting an specific actor is not working either, or how do you think it should be done, could you please show a BP image?

      thanks
      Last edited by RoccoFX; 09-04-2018, 12:12 AM.

      Comment


        #4
        As @GarnerP57 said. You have add cast to [your projectile class] between your actor class variable and spawn actor. Also if your actor class is holding only projectile class and you are using it only here, you can just set the projectile type there and you no longer need any casts.

        Comment


          #5
          I sometimes get this issue. What you need to do is unhook your ActorClass getter from the SpawnActor node. This converts the Class pin to a drop down list. Select your class for the list. Then, you can hook up all your outputs again and they will work. Then you should be able to reconnect your ActorClass getter again.

          Comment


            #6
            Originally posted by goatsucker View Post
            I sometimes get this issue. What you need to do is unhook your ActorClass getter from the SpawnActor node. This converts the Class pin to a drop down list. Select your class for the list. Then, you can hook up all your outputs again and they will work. Then you should be able to reconnect your ActorClass getter again.

            It is not an issue. It is designed this way. The compiler needs to know ahead of time what class it is dealing with in order to assign a value to a specific class. That is what casting is all about. You let the compiler know what type of class you expect it to be and more importantly what it can't be and it will allow you to work with that particular class before it even exist.

            If the SpawnActor node is fed an Actor class variable and during run-time you assign a Car Class with a variable named MaxSpeed this is not known ahead of time and therefore it can't be assigned without casting first.

            If on the other hand the SpawnActor node is fed a Car Class and during run-time you assign a Toyota that is a Car Class you will still be able to assign MaxSpeed because it is already known by the compiler ahead of time.

            Comment

            Working...
            X