Download

Casting Question

Hello, So i’m trying to cast the defualt MyProjectile to my custom gun blueprint but im still kind of new to blueprint.I have made what i thought the way to do it would be but it does not work. I want it to cast the projectile to leftclick when the player has the gun only and find the offset of the gun so it shoots out the barrel. I have a picture below of what i thought would work. Can someone tell me what i did wrong?

I’ll try to explain to you what is wrong.

You have 2 trigger that seems to be able to fire the gun. That means 2 different paths to come to the point where you want to fire your projectile.

However, one of the paths, the top one can NEVER fire. Because the branch you have depends on data from the other path… and since you can only follow one path(the white line) at any given time, the top one will never work.
And even then, the top one doesn’t do much.
Let me explain step by step what your 2 cast nodes does;
You take a gun, put in a box and label it “stuff”, and then you pick up that box that says “stuff” and see if there is a gun inside it.

The bottom line, inputTouch event, can supposedly work. But… it depends on data from the top event, so all you blue lines from your casting are containing nothing, it is empty.
So you’re trying to get the location and gun offset of something that doesn’t exist.

You have to understand 2 things.
White lines carry no information, it is only a step by step guide for the computer to tell it what to do. It is impossible to execute 2 of the white lines at the same time. so you are either doing one thing, or the other, never both. Once you reach the end of a white line, no more nodes, everything dies. no information is remembered unless it is stored in a variable.

Data is carried by the colored lines.
If you try to get data from a path that has not been executed previously by your white line, the data will not be there. And remember, the computer doesn’t know if you have travelled on another white path before… it can only remember the white path it is on right now

I will once again point you to the tutorial videos.