So I am making an angry birds type game and I am trying to figure out how to make the projectile actor follow the mouse cursor while the player is pulling back to decide force and direction of aim?
I have it set up to where the player can pick which projectile they want to shoot and then once they do it spawns it in the “slingshot” area in which the player can then pull and release to shoot the projectile.
Try the following logic (in the player controller). If you position an object at the resulting vector each frame, it should follow the mouse perfectly.
Note: Our camera is positioned along negative Y and we don’t have any rotation (it looks straight down Y). If yours is somewhere else, you may need to jiggle the logic around a little. This also presumes that your ‘game plane’ is at 0.0 Y in your world. Either way, it should get you started.
No but when I hook it up to the onTick event the camera goes crazy and looks like it gets pushed back. The value of the x changes the y stays the same. The camera is facing directly down the Y axis right now.
Well, I’m not sure what to suggest at all now. All I can do is provide a few pointers:
You should have an object in the world or in a blueprint as a component.
The player controller should be generating the result of that vector (has to be the player controller, it has the mouse input stuff). This has to be done on tick (every frame).
You either need to give the player controller access to the object (so it can access it’s world location), or send the value of that vector to the object.
Use ‘Set Actor Location’ (Might be ‘Set Actor World Location’) and set it to the value of the vector.
If you’ve done it correctly, the actor should follow the mouse perfectly (or be doing something close, so you can work out what you need to change to make it work for you).
Regarding the camera. If the camera’s moving - maybe it’s being updated by the player controller… You’re not moving the player controller? (Or a pawn it’s attached to?)