Download

Cast to a certain component within a blueprint

I watched a lot of youtube tutorials and from what I understood it is that in my case the collision volume asks if it gets hit by the “FallDown” Blueprint. If yes then it ignites the fire and so on.

And I wondered if its possible to ask if only the red cube inside the “FallDown” Blueprint hit the collision box and if yes then…

:smiley:

You’re right about the casting there.

Basically casting says ‘is this thing, one of these’?

But you can’t cast ‘inside’ a BP, it just tells you what kind of thing it is.

I’m just putting a demo together, which will let you know which cube is overlapping…

1 Like

Ok, so in this case, it makes most sense to do the operation from the point of view of the BP with the pair of cubes. Like this:

ezgif.com-gif-maker

There is a collision box around each cube.

I can do a version just from the point of view of the ‘sensor’ if you like. But that involves ‘component overlap component’, not casting, and is the hard way to do things.

1 Like

Thank you so much! :smiley:
Is it very hard from the view of the sensor?
I don’t want to steal your time but I am curious :laughing:

Just trying to get it working actually, it’s not pretty ( although I did actually use it in my game… )

So this is what you get the other way around. The upper text is the same as before ( what the 2 cube BP sees ), the lower text is what the sensor sees, ‘looking into’ the 2 color BP:

other way

The code in the sensor is:

See what I mean? Don’t do it that way… :wink:

1 Like

Thank you :smiley:
This looks very complicated but I will puzzle with it to learn how it works. The first example you made looks easier and lighter.

And the last 2 days I was trying to add a component from within the BP in the object slot of the cast node :smiley:

So you helped me a lot. Thank you :smiley:

Nope, that wont help… :wink:

It takes a while to understand what casting is for, and it’s NOT to communicate with blueprints :smiley:

You know how you have classes in Unreal? Different types of things. Casting does two things

  1. Tells you if you are faced with an item of type X

  2. Converts an item of type X into an item of type Y, IF ( big if ) Y is a sub class of X.

A lot of people get obsessed with casting, thinking it’s a way of talking between BPs, but you can talk between BPs fine with ‘direct communication’ ( as it’s called ).

Lot of very wrong tutorials on youtube about that…

You are right. I was thinking the same about casting. Like it is for communication. I will look into “direct communication”! I start to understand what classes are :smiley:

The thing is, very often you cast to check if an overlap is being caused by a certain kind of object ( like the player ). You’re not communicating with the player, you’re just checking, ‘is that a player?’

But: when you do that cast, you get a reference to the player ( if it was a player ), so you might as well use it.

That’s what leads to the confusion.

And the “cast to” node only checks if ifs the player or pawn and not if its the right hand of the player, right? :laughing:

Correct. Again, that would be easier in the player, because the player has all the relevant info.

If it’s really needed, the player can then tell the other BP, ‘hey, my hand just touched you’…

1 Like

Thank you! I will look into this next. Communication :smiley:

Get used to this guy, you’ll be using him a lot:

1 Like

Thank you so much. So much to learn :grin: :grin:

1 Like

@cookieesutra While this is not about casting at all, here’s another solution to the FallDown situation, using tags:

2 Likes

Hello!

Nice! I will play with this solution as well :smiley:
Thank you! :smiley:

Hello,

I wanted to give some feedback on my progress :smiley:

I made the 2 cubes rotating. One is the FireBox with the tag “Fire” and the other is the ExplosionBox with the tag “Explosion”. When it is rotating FireBox ignites one cone and ExplosionBox makes the other cone exploding :smiley:

This setup works so far:
(Blueprint is inside the trigger box Actor)

Oh and I wanted to ask how you made this gif :smiley:
Are you able to test blueprints in the viewport by moving the actors around or is it an animation?

Polly

If you play in simulate mode, you can do most things, without getting wrapped up in a pawn:

Screenshot_1

1 Like