I am trying to make a gun with the first person shooter blueprint preset, and I have tried many thing to try to get it to work, but I can’t get the player to teleport to the point where a projectile hits. Does anyone know how to get it to work?
When the projectile “hits” something fire off a hit event that stores the hit location. Then pass this info to the player character somehow (cast to, interface etc) and then “set player location” to the hit location.
Maybe build off something like this:
Edit: Forgot to add a branch, you want to check that the overlap is the projectile of course:
A few ways. Right click and type it in for one. Another is selecting the actor component you want to detect the overlap, looking at the right side and scrolling down until you see the green “+” bars. There are lots of different options.
In my example I used the main capsule as that’s the one you usually want.
How do I get the “On Component Begin Overlap” block?
Well, thats can end up being a wee bit backwards. See the projectile hits your character right? And your character is the one who is teleporting? If so, you would want to do capsule component on actor begin overlap, use the branch to check if it’s a projectile, or the specific projectile you want to teleport to and then set the actor location.
But I suspect your are doing some sort of shadowstep ability? Ie you shoot an enemy with a special arrow or some such and then teleport to it? In that case you would use the projectile on actor begin overlap and a query for checking if it is an enemy AI and then teleport to it via Set actor location with target get player character. I’d handle the check with a tag query in that cas myself. Ie, I give all my enemies a tag called “Enemy” and sometimes additional tag like “Boss” or “Minion” to make sure some abilties or status effects can only be applied to the correct character (for example you can’t stun a boss).
So a shadowstep type of ability. Alright then. Firstly, the projectile should be an actor that you spawn when shooting the weapon. Providing that’s alright, set its collision in the capsule in the actor blueprint to overlap world static (or you could make a special type if you want, either way). Then click the capsule in the component list, look at the details on the right side (to the right of the viewport) and scroll down. There you will see lots of green plus boxes. Choose on actor begin overlap (click the plus).
I can’t test this out right now and I’ve never done this but instead of other actor in the node you’d drag out component and choose static mesh. Then set up the teleport as described.
Drag out and type in ==
It checks if actor/component is a specific type.
First, I can’t find the “On Component Begin Overlap”, and second, I just want the gun from the First Person Shooter template to shoot it’s projectiles, hit a wall, and teleport the player there, like a Portal Gun from the Portal games, but simpler. Sorry for being confused, I forgot to mention that I just started.
What is the block that you used that is below the branch?
Is that code supposed to get it to teleport the player? Because it isn’t doing anything.
How do I use the node to get the player character?
No its not. You need to select what it should overlap for the branch to be true for one. As I said, build from it. May need more components.
Remove firstpersoncharacter and use the node get player character.
You plug it into target
Are you making it in multiplayer? If not, you don’t need it.
How do I get the player index?
I am really confused as to what is so difficult here. The basic mechanic is simple, making it look good, (lerping locations, setting up a projectile that isn’t the exact FPS projectile with its physics enabled etc is the real work) I literally opened up the FPS template and popped this node in and it does exactly what you want.