change power by changing actors (resolved)

Hello, I would like to know if the power can be changed when my character evolves. the two powers emerge from a box. each actor contains different powers

cap1

there I should change power
the leaf should come out

here the two actors

1 is the mushroom box
2 is the leaf box

here in the mushroom

here in the mushroom box

By the way, this is how the leaf box works
cap6

1 Like

Hello @Hector40 the way I would do it is by just creating 3 actors BP_Power_Up_Cube and the other two actors BP_Mushroom and BP_Leaf.

The cube has a variable that holds the class that’s it’s going to spawn when hitted. The default value for this variable is BP_Mushroom.

When the mushroom power up is spawned and picked up it gets all power up cubes in the world and set their Power up actor class variable to BP_Leaf.

If you need help setting that up let me know I will be happy to help.

Hello, thanks for answering. I had already created two actors and made their release independently in their respective boxes.

here are the knots so that the powers come out

@Hector40 Great you have your power ups actors. Now you just need only one cube not two.

  1. In this cube create a variable and call it something like PowerUpToSpawn
    Screenshot 2024-02-12 223441
  2. Here is the spawn event
  3. In your BP_Mushroom
1 Like

How did you achieve this?

@Hector40 That is just a custom event i called it “your existing code” just so you can see where to put it

1 Like

does not work :grimacing:

@Hector40 Are you actually calling these events somewhere? Of course it’s not going to work if you don’t call them.

And instead of getting the actor transform you have to get the location/rotation where you want the power up to spawn. If you can’t figure that out just put an arrow component on top of the cube and get it’s location split the transform input and plug in the arrow location.

In the event Your Existing Code I just used it to show where you have to put the code for what happens when Mario picks up the mushroom. So you have to replace the print string with that.

After all of that make sure that you call your custom events when the cube is hit and when the mushroom is picked up.

1 Like
  • after Mario has powered up, will every block spawn a leaf, or every block will spawn something different, unique?
  • when Mario powers up, what actually happens? Do you just change the mesh or do you spawn a new character class to control?
1 Like

Yes, each block generates a leaf and the other block generates the mushroom

a new character is generated

here I call the event but it generates an error

the only thing I have in the mushroom is this

I think the whole Get All Actor of Class is not a good idea. Would this work for you:

  • in the block Mario hits with his head:

That’s pretty much it. In your very case, I think it’s this:

Is the part that spawns the mushroom?

Yes, it is the part where the mushroom is generated

How do you call it then?

in the same box actor

It would probably be very close to:

  • in the box:

In short:

  • when Mario hits this block, we check which class it is
    – if he is normal, we Select False power
    – if he is evolved, we Select True power
    – we store the result in a variable Power up To Spawn for later
  • once TL completes, we spawn a new power using the variable

You should consider inheritance, so you do not need to script it again in every single block class.

1 Like

I tried here but it tells me an error in two nodes

You already had those nodes connected to some data, have a look at the previous pic you posted yourself.

Marked in green. Keep that part as it was. You don’t need to add a new timeline or events, you already had them.

1 Like