Hey all. Been trying to figure this out for a few hours with no luck.
The concept of my idea is essentially similar to pool/billiards. You have a top down view, and you’d click on the ball, drag in a direction, and release, and the ball would shoot in that direction, with the force applied being larger the longer your drag was from the object.
Basically the logic in my head is something like:
- When you click, set a vector for the position of the ball actor
- When you release, set a vector for the position of the mouse
- Then, apply a force to the ball as some combination of the above vectors 4. Then some other stuff that probably doesn’t matter for now such as, you can only do the starting click on the ball actor, as opposed to anywhere in the level
However I’m having a few issues.
When I put the logic in the Sphere Blueprint (the ball), I can only get the mouse click/release to work when the cursor stays on the ball. (I want the initial click to be the ball, but the release can be anywhere)
So I tried to put the logic into the Player Controller, but I can’t seem to figure out how to reference the sphere in the Player Controller. I get the error where I don’t have an instance specified. In normal blueprint to blueprint communication, I can specify the instance in the details menu, but for the Player Controller blueprint it seems to be different.
Technically I have no player controller. Since it’s a top down puzzle game, the player is “god”, and I have my camera actor set to “Auto Activate for Player: Player 0”.
To be honest, I’m not sure if I’m approaching this correctly. Perhaps I need to make the ball a pawn, so it gets possessed by the player? But then I don’t know how the camera would work, so I don’t think this is right.
Currently in my level I have these elements (excluding things like light actors): Camera Actor (gets auto activated), Floor, Sphere_BP (the ball that should get moved).
Essentially I nothing more than the standard Puzzle template, outside of a new map with a floor and a ball on it.
If anybody could point me in the right direction I’d really appreciate it! Just struggling on where to put this logic.
As some additional notes, I did look at this thread: https://answers.unrealengine.com/questions/328918/drag-back-object-and-release-to-apply-force.html
And this looks like what I’m looking for, however I’m having trouble figuring out WHERE to put the logic, as I mentioned above.
Thank you!