playMaker

Author Topic: Tap to Shoot Ball  (Read 391 times)

heavygunner

  • Sr. Member
  • ****
  • Posts: 340
    • View Profile
Tap to Shoot Ball
« on: November 22, 2020, 03:59:39 AM »
Hello !

See this video. I am trying to create something like this. I did ball movement. Gravity enables sphere and added force on Z axis (No every frame)

I couldn't figure out that how the shooting ball working. It is not spawning on Cannon. But, from middle of the screen. How to do tis exactly ?

Plus, ball moving direction depend on where you tap. Any idea?

« Last Edit: November 22, 2020, 04:02:58 AM by heavygunner »

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
    • View Profile
Re: Tap to Shoot Ball
« Reply #1 on: November 22, 2020, 06:38:36 AM »
Hi heavygunner,

First thing that comes to mind is Screen To Word Point for the touch (for the bullet) to go in the direction of where you touch. Also you can use Raycast.

If you wanted to rotate the gun in the touch direction Im not quite sure how to go about that (possibly a look at or smooth look at?).

I to me it looks like its spawning from the from the cannon (but you can put your spawn point anywhere), it looks as though the player moves faster than the bullet speed (when the player jumps across the bullets are catching up).

I found this video which should be super helpful:
« Last Edit: November 22, 2020, 06:47:17 AM by Kodagames »
Have I said how much I love playmaker!!! This is one amazing tool

heavygunner

  • Sr. Member
  • ****
  • Posts: 340
    • View Profile
Re: Tap to Shoot Ball
« Reply #2 on: November 22, 2020, 09:22:48 AM »
Hi heavygunner,

First thing that comes to mind is Screen To Word Point for the touch (for the bullet) to go in the direction of where you touch. Also you can use Raycast.

If you wanted to rotate the gun in the touch direction Im not quite sure how to go about that (possibly a look at or smooth look at?).

I to me it looks like its spawning from the from the cannon (but you can put your spawn point anywhere), it looks as though the player moves faster than the bullet speed (when the player jumps across the bullets are catching up).

I found this video which should be super helpful:
Thanks, Earlier i skipped this video as there is no ball  ;D
Watched it.

Is this the action you talk about ?
https://hutonggames.com/playmakerforum/index.php?topic=2921.0

So, Spawn the ball and make it too lkk at where we exactly tapped last time? correct me if I'm wrong.

Thanks again

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
    • View Profile
Re: Tap to Shoot Ball
« Reply #3 on: November 22, 2020, 08:06:33 PM »
Hi heavygunner,

Its been quite sometime since I did this (rusty, always difficult for me to get the raycast working properly) but had 2 thoughts hope these can at least point you in the right direction:

1) State 1, Touch Event,
State 2, Get touch Info - normalize and store position, then Screen To World Point, set the screen vector to your stored stored position (previous action), set a variable for the Store World Vector (this info can be passed to your bullet along with adding some force in the z).

2) State 1, Mouse Pick (I'm not sure if this works on mobile or not because you mentioned touch?), store the hit point, also have a Get Key Down or Touch event to send you to the next state.
State 2, shoot your bullet and give it the hit point
 
When I get some time on Tuesday evening I'll try and figure out how to do it with the raycast actions.
« Last Edit: November 22, 2020, 08:10:45 PM by Kodagames »
Have I said how much I love playmaker!!! This is one amazing tool