examples of how pickups are handled

Started by
12 comments, last by ethancodes 5 years, 10 months ago

Hmmmm this is closer I think but it's not always the Paddle it will collide with, sometimes it might be the ball. If I made the PowerUpManager static and put it on the ball and the paddle, would that male it so it would all track in one place no matter which object the pick up hits?

Advertisement
1 minute ago, ethancodes said:

Hmmmm this is closer I think but it's not always the Paddle it will collide with

Then just add two collisions or do an or check.


if(col.gameObject.name == "Player1" || col.gameObject.name == "Ball")

Other possibilities is to give the ball and the player the same tag. Moving them to the same layer also allows for layer checks. You could even add a variable to the objects and check for it on collision.

There really isn't a way around this; you will always make more code the more you need to do.

 

With that said, learning the observer pattern is a good thing if you want to try it just to learn. You will use it a lot in complexer games. It's just that most of the code Unity uses already follows this pattern.

I really want to learn the observer pattern, however I think I found a solution that is going to really cut out a lot of code, so I'm going to go with that. 

This topic is closed to new replies.

Advertisement