Announcement

Collapse
No announcement yet.

How to get variable from other blueprints?

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

  • replied
    OMG you rock man. All I need is that concept of casting. I know a bit of OOP but not that into it. I got all my bugs fixed as long as I googled how to use Blueprint Casting. Thank you a lot and have a nice day!

    Leave a comment:


  • replied
    Yes, you want to cast the "OtherActor", to the Class it has.

    I assume the screenshot is inside the Bullet Blueprint. The "OtherActor" from the Overlap is everything you collide with, so i might be the block.
    You can get the OtherActor (pull the pin out) and type "Cast to ... " and "..." would be the Name of the Block class.

    If you create this Event in the Block, you can cast the OtherActor to the Bullet.

    Of course(!) the Cast will fail if the OverlapActor is NOT the Block (or bullet, depends on the cast), so the you are also filtering the correct
    overlapping actor and don't let other things execute everything behind the cast.

    You could also create custom overlap types and make sure that only the bullet and the block can overlap, but that's a bit more advanced.

    So, let's assume you create the OnBeginOverlap in the BLOCK. So you can cast the OtherActor to "Bullet" and get the color from the CastResult.
    Since you know object orientated languages, you should know what casting is and does.

    The error Unreal gives you just says, that OtherActor (of type ACTOR) is not compatible with a pin that wants a "SHOOT" reference.
    Why does it want a SHOOT reference? Well because the Function you want to call only exists in the SHOOT class. The ACTOR class does
    not know about this function.

    Leave a comment:


  • replied
    See that blue connector on the left side of Get Colors marked "target [self]" connect your Other Actor there....or from other actor do drag off to "Cast To" then connect to Get Colors.....

    Leave a comment:


  • started a topic How to get variable from other blueprints?

    How to get variable from other blueprints?

    I am new to unreal engine and I am trying to make a 2D game. The character is just a ball that will shoot bullets to cancel blocks. It's just like space invader but the mechanics of the game is that the player should suck colors from different regions. Once you get the right color, you shoot the blocks with that color to cancel them. If you shoot the blocks with wrong color, you lose one health.

    - The idea is simple, but how do I do this kind of judgement "if the block matches the color of bullet"?

    I tried to create a "getter" function to get color according to the flipbook that the bullet has (and assign an integer index to it). My idea is just use something like "theBulletInstance.getColor()" (I'm using blueprints to achieve this kind of thing) and compare the return value to the color in block which is save as integer index. This is how I normally get things in object-oriented programming languages like JAVA. However, it looks like i didn't seem to get the right object (bullet) in my blueprint.

    - How do I call the getColor function in the object that is in contact with the block and then make a judgement of the color match then decide if the block should be canceled?

    I tried to right click and put an Event ActorBeginOverlap while my bullet class is selected. But when I plug the "other Actor" pin to the target pin of my getColor function pin inside event graph of my block class, unreal tells me that Actor reference is not compatible with Shoot reference. ("Shoot" is the name of my bullet class.)
    Click image for larger version

Name:	Screen Shot 2015-11-04 at 4.33.52 PM.png
Views:	1
Size:	365.2 KB
ID:	1166342
    Any help will be appreciated!! Also, thank you for reading my post!
Working...
X