Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Haserhud on January 28, 2020, 06:48:18 PM

Title: Screen boundaries for player? (2D)
Post by: Haserhud on January 28, 2020, 06:48:18 PM
First I want to say thanks to the community for being so incredibly helpful to us beginners.

How do you create screen boundaries for the player in a 2D SHMUP?

I tried first by creating some large invisible sprites with box colliders and made them surround the camera view scene. This does work in that it restricts the player, but it also restricts other objects too. I want ONLY the player to be restricted by the boundaries.

Any suggestions would be greatly appreciated!

Title: Re: Screen boundaries for player? (2D)
Post by: Thrump on January 28, 2020, 08:29:22 PM
You can achieve this using layers.

Create a new layer called Player and put your player on this layer. You can add and assign layers at the top of a prefab/gameobject in the inspector.

Then assign a new layer to your boundary objects.

Then go to Project Settings window, Physics 2D section. At bottom, look at Layer Collision Matrix. Make sure there's a checkbox for every layer that should collide with your new layers. For the boundary object layer, uncheck for every other layer than the player layer.
Title: Re: Screen boundaries for player? (2D)
Post by: Haserhud on February 12, 2020, 05:16:52 PM
You can achieve this using layers.

Create a new layer called Player and put your player on this layer. You can add and assign layers at the top of a prefab/gameobject in the inspector.

Then assign a new layer to your boundary objects.

Then go to Project Settings window, Physics 2D section. At bottom, look at Layer Collision Matrix. Make sure there's a checkbox for every layer that should collide with your new layers. For the boundary object layer, uncheck for every other layer than the player layer.

Thanks Thrump!

Would this also work when using a moving/scrolling camera, or should I use a different method for that?
Title: Re: Screen boundaries for player? (2D)
Post by: jeanfabre on February 14, 2020, 06:00:33 AM
Hi,

 you should also learn Cinemachine, you can automate this most likely

Bye,

 Jean