playMaker

Author Topic: How to make 2D Basketball goal net?  (Read 266 times)

ludens

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
How to make 2D Basketball goal net?
« on: March 15, 2019, 11:45:37 PM »
Hi. I'm trying to make 2D platform basketball game like Bouncy Hoops. ( )
Sadly however I don't know how to make goal net (which jiggles whenever collided by balls)
Could you help me to solve my problem. Thanks for reading it :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4178
    • View Profile
    • jinxtergames
Re: How to make 2D Basketball goal net?
« Reply #1 on: March 16, 2019, 11:01:16 AM »
Hi.

for2D You can use 2 circle Collider 2D, one near the back board and at the end of the net, and have 2 box Collider2D in between and set to trigger.

1 box at the top side , to register that the ball came in from the top.
and one below it, to register score.

for bounce you need to create a Physics Material 2D and place them on the Collider components.

play around with the Physics Material 2D settings to get the desired effect

you could also add one to the backboard and make it a little less bouncy for example.

for the jiggles, use collision 2D Event.
Then on collision you can animate the jiggling.

To animate you can use some tweening or the animator.

you could get the force of the collision and use that to determent how hard to jiggle.

in the animator you could use the (force) float for the force to check condition  and
do animation accordingly.

in playmaker you could use float switch for example. to determent how hard.

Thore

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: How to make 2D Basketball goal net?
« Reply #2 on: March 16, 2019, 02:40:05 PM »
Hi, look into the cloth component. E.g.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4178
    • View Profile
    • jinxtergames
Re: How to make 2D Basketball goal net?
« Reply #3 on: March 17, 2019, 09:06:33 AM »
Hi.

I misunderstood the question maybe.

but you could use the same trigger on my 1st post that triggers the score to animate the net.

On the video it is just an animation triggered.
But if you want more dynamic, the Cloth component that Thore mentioned is the way to go.

ludens

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to make 2D Basketball goal net?
« Reply #4 on: March 17, 2019, 09:31:13 AM »
Thanks for your kindful reply.
I've watched that video but still can't understand how to use it to my 2D game because that video only shows 3D example.
Could you give me hints about applying Cloth system to 2D games?


Hi.

I misunderstood the question maybe.

but you could use the same trigger on my 1st post that triggers the score to animate the net.

On the video it is just an animation triggered.
But if you want more dynamic, the Cloth component that Thore mentioned is the way to go.

Thore

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: How to make 2D Basketball goal net?
« Reply #5 on: March 17, 2019, 12:30:55 PM »
Unity is always 3D, and can use 3D visuals, but you may need to get creative to combine them with a 2D setup. But if you don’t want to use 3D for technical or aesthetics, you can do it in other ways. Here are three:

1) sprite animation, as used in your example. You need to draw the animation as sprites, and trigger the correct one. See beginner tutorials on how to do sprite animation. This was used by the example you gave.

2) skeletal 2D, combines bones, i.e. the net is made out of parts which are animated using a rig of bones. See beginner tutorials on this technique. The advanced variant uses a deformable mesh based on a sprite, that is also hooked up to bones.

3) 2D physics based, which can be done (maybe!) using net parts connected with joints. Search for unity + 2d + rope to see tutorials how to make this in Unity.

The animated versions require game mechanics that can detect hitting the hoop and net, probably from at least two sides (two trigger colliders) and going through (third trigger collider) to play the correct animation. You anyway need them, to detect that the ball goes through from above, but not from below etc. It seems simple, is fairly intricate, but manageable.

ludens

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to make 2D Basketball goal net?
« Reply #6 on: March 17, 2019, 06:45:53 PM »
Then can I use only those 3 methods to 2D Games?
Can't I use Cloth component with 2D colliders?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4178
    • View Profile
    • jinxtergames
Re: How to make 2D Basketball goal net?
« Reply #7 on: March 18, 2019, 01:46:54 AM »
Hi.
There is a video showing that you can use 2D colliders but its not showing how.

I can see that a script is used and particles, so it will be pretty complex to set that up.

You could add a 3d collider to the ball, to interact with the cloth.

ludens

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to make 2D Basketball goal net?
« Reply #8 on: March 18, 2019, 02:11:06 AM »
That's good idea! I'll try it. Thanks for your advice :)