How can I create top down mouse-driven aiming? (Crosshair follows cursor, fires projectiles at cursor location)

If its a custom made pawn. Try getting the Worldspace Location and reference the mesh that represents the player in game.

Like this?

Still doesn’t work.

Are you using one of the premade examples? I will try to recreate this, and figure out why its doing this.

Nope, it’s made from scratch.

http://puu.sh/7Uslo.jpg

I’ll be trying to tackle this again over the weekend, I’ll let you know if I get anywhere.

I attempted this myself with the Top Down Premade Blueprint code and produced this. I noticed in your screenshots that you did not reference “Get Controlled Pawn”. Let me know if that does anything, because that pulls my location fine.

Using the Top Down Premade Blueprint Example, this is what I was able to produce. Notice I use “Get Controlled Pawn” node when referencing my Actor. Let me know if that does anything for you. Without it, I noticed it only shoots from the start location.

Hmm… that’s weird. I get an error when I set it up like that, even though it is a pawn class.

3278-ss+(2014-04-05+at+11.38.37).png

Nice, I got this to work as well, darkPivot, I tested this with the top down BP example as well, you may want to just have a look at the way the controlled pawn is set up in that example to see if it matches up with your set up.

This still however doesn’t have the projectile fire at the mouse position, but at least it will always spawn from your character regardless of position…Halfway there :slight_smile:

Throwing another possible solution into the mix… There are multiple ways to handle it, but one could do it this way too:

You’ll have to experiment and see what works best for you.

-W

Try adding “Get Player Controller” node to the target of “Get Controlled Pawn” node.

This solution is elegant, for your input. I could not figure out how to use the Find Look at Rotation properly. I was using my solution to get the X/Y coords to resolve the location in game. But I overlooked, that getting the hit location from the mouse was already possible.

I’m starting to think it’s because my controller/player setup is incorrect. In the top-down demo all the code is in the player controller, and the pawn itself has no code. However, I don’t understand how to reference my pawn when putting the code into the controller, unless I’m understanding this wrong.

Would anyone like a basic youtube video on this setup? I’ve managed to get a basic skeleton working locally and IMO it’s pretty straightforward.

I’m still new to UE4 so maybe we could all learn together :slight_smile:

That would be great! I’m still stuck on this unfortunately, so this would be really helpful. .

Sure! I’ll record it tomorrow and link it for you :slight_smile:

Hi DarkPivot - others who have attempted this solution,

I have a video using the Top Down Blueprint Project utilizing this solution. Specifically, the solution provided by Wes Bunn.

Shooting Projectile at Mouse Location Video Tutorial

I created it in such a way that anyone can follow, those like DarkPivot who have custom projects will have to adapt this to their own actor classes. I hope this sheds some light on the solution.

Hey there, as requested I’ve uploaded my mouselook tutorial :slight_smile:

I’ve not done any tutorials before so I think it was a bit bumpy at times x_x.

Edit:
Part 2: Optimizing the rotation & moving the pawn - YouTube .

a lot!

How about this for a twist. I bought L Newton’s ATS which is awesome, but it’s a lot more than I want actually. I want to be able to click on one enemy AI (Select it), and shoot at him with my hero character. Is the method above a good starting point or am I way off??

in advance, and if you’re reading this, great stuff!