How to constrain a HUD to the camera without putting it in a non-scrollable layer?

owen_dennisowen_dennis Just a guy, you know.Member, PRO Posts: 236
edited February 2015 in Working with GS (Mac)

I've got a game where the camera scrolls around. I also have a HUD on a non-scrollable layer (it looks like letterboxing from a movie). I have a weapon I'm using that's a bouncy ball and I want it to bounce around within the letterboxing HUD, using the HUD as the collision objects instead of stuff in the game world. The idea is that the player can move the character and the camera around to different parts of the level while the ball bounces crazily within the HUD.

The ball bouncing and understanding the character's velocity etc is totally fine, however it doesn't interact with the HUD when it hits it, even though I have collision detection on and the black bars are checked as moveable objects. It seems like this is because of it being in a non-scrollable layer. Any idea on how to fix this?

I've been thinking that one possible way to do it is to constrain the black bars to the camera without them being in a non scrollable layer. How could I go about doing this?

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @octopus1138 said:
    . . . constrain the black bars to the camera without them being in a non scrollable layer. How could I go about doing this?

    You're answering your own question - not sure what you need to know in addition to what you've already said yourself . . . ? To constrain something to the camera without it being on a non scrollable layer you need to constrain it to the camera and make sure it is not on a scrollable layer ! :smile:

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2015

    Quick example file attached: (arrow keys move the main actor).

  • owen_dennisowen_dennis Just a guy, you know. Member, PRO Posts: 236

    @Socks said:
    Quick example file attached: (arrow keys move the main actor).

    haha, well on the plus side, I'm glad I'm going the right path. That example is both funny, and almost perfect. The problem is that because it's now constrained to the actor, the actor can't move a little bit in different directions within the scene. Like how in most platformers or something the actor moves a bit in a direction and then the camera starts following him. I opened up the scene in the example and the camera's frame is really tight so that little red square can't start in a direction first, and then have the camera follow him.

    So I guess that's what I'm looking for. That's why I'm saying that the black bars have to constrain to the camera, and then the camera has to constrain to the actor so there's a little bit of the actor being able to move around inside the frame before the black bars and the camera follow.

  • SocksSocks London, UK.Member Posts: 12,822

    @octopus1138 said:
    . . . so there's a little bit of the actor being able to move around inside the frame . . .

    Just constrain to the camera instead of the actor, hold on, let me adjust the demo . . .

  • SocksSocks London, UK.Member Posts: 12,822

    Here, try this (file attached):

  • owen_dennisowen_dennis Just a guy, you know. Member, PRO Posts: 236

    @Socks said:
    Here, try this (file attached):

    Haha that's exactly what I wanted. That's so simple. Why is it I can understand tables but not a simple camera constraint? Weird. Thanks a lot! I really appreciate it.

Sign In or Register to comment.