Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: RC on February 23, 2016, 10:50:09 AM

Title: Addforce to mouse positon?
Post by: RC on February 23, 2016, 10:50:09 AM
Hi,

How do you shoot a bullet toward your mouse  position?
I'm having trouble understanding how I would add an offset for the bullet to go toward the mouse position.

I have look at the canon game that Jean made, but it's not what I'm looking for.
Any help would be great!

Thanks
Title: Re: Shooting at an angle 2d.
Post by: RC on February 24, 2016, 09:44:54 PM
For a better understanding of my question, I have found a youtube video of what exactly that I wanted to do. I'm sure other on here would love to learn how to do this also.

Please share your experience, Thank you

Title: Re: Addforce to mouse positon?
Post by: Ghosu on February 26, 2016, 12:57:22 PM
One quick method i just tested:


plane (like the white background in your video) with collider set to trigger
you can delete its mesh renderer to make it invisible and translate it to the players position

FSM on your arm/hand/gun or whatever you want:
action mouse pick, store point, every frame

action smooth look at, target position: point
play around with up vector/keep vertical/speed to fit your demands or rotate you mesh/parent

... and with mouse pick event at mouse down you could simply create a bullet prefab at position gun. This prefab uses a translate, move or force action heading its lokal front position.


That's just a quick way you could tweak and build on.

Greetings