playMaker

Author Topic: Can't figure out how to make a projectile  (Read 3065 times)

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Can't figure out how to make a projectile
« on: May 28, 2012, 08:28:53 PM »
I'm trying to make a fireball appear from the player, and move in the direction the mouse pointer is pointing.  However, I don't want it to STOP where the player is pointing, just to be shot at that point and continue for a certain amount of time.

How would I do this in code?

I imagine that if there was an action for actually just moving towards a point, and the beyond it (same vertex slope I guess?) then I could just do a wait function to eventually kill it.

The Move Towards action will stop at the specific point, not actually continue past it.
« Last Edit: May 28, 2012, 11:14:45 PM by Disastercake »
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Can't figure out how to make a projectile
« Reply #1 on: May 29, 2012, 02:24:17 AM »
Hi,

 yes, you are right, maintain a "direction" instead of a target so to speak.

 compute the direction of the projectile between the user and the mouse and then animate the projectile to a far greater distance, for example up to your maximum distance, that when the projectile reaches simply explodes or simply disappear.

does that make sense? You can achieve this by for example multiplying the vector between the mouse and user by 3 or 4 or 10, this will essentially keep the same direction but be far longer in magnitude.

Bye,

 Jean

Vermz

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Can't figure out how to make a projectile
« Reply #2 on: August 06, 2012, 01:57:22 AM »
Hey Jean,

I am in a similar situation working on a top down game and I have gotten to the point where I create the object and attempt to send the projectile in the right direction. Currently I am pulling the V3 of the Mouse World Coords using the Point captured from MousePick actions.

What I am currently banging my head against is moving the projectile in the correct direction. I've tried using translate sending the objection the V3 from the Mouse Coords but it doesn't move in that direction. The way I have set it up currently, Get Angle to Target,  player weapon projectile spawn point to target being the vector3 containing the mouse coords. I then use a smooth look at to have the projectile face the direction that was last clicked and it was to travel.

As of right now I need help establishing the best route to get this projectile to move. Images below. The functionality I am looking for exactly is where ever the player clicks their mouse - the vector is store - and taken and used to have the projectile travel within that direction. Destroying itself upon impact or continuing out of gameview.

Thank you for your time
« Last Edit: August 06, 2012, 02:12:47 PM by Vermz »

Vermz

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Can't figure out how to make a projectile
« Reply #3 on: August 06, 2012, 01:59:11 AM »
I finally got the translate to work as you mentioned before by multiplying the vector. But the issue I am having now is having the projectile will follow the mouse cursor and wont stay on its initial direction. It will keep following the most current and updated mouse position. Is there a way to pull that value and store it so it will not keep updating?

Update: I resolved this problem by turning off the Every Frame Check under the Mouse Picker action. This stopped the homing projectile problem and gave me the store variable correctly. In the future, if I find the time or someone else does, an example of a projectile created via transform and/or with raycast to help other noobs who run into this problem. This is the one example I didn't see out the vast array of tutorials for playmaker and would definitely prove fruitful for new comers down the road.

Even though I resolved these problems I still feel that I might not have built the projectile translation appropriately
« Last Edit: August 06, 2012, 02:11:18 PM by Vermz »