Any alternative to using control camera? I need to disable when actor falling!

karlpowerkarlpower Member Posts: 17
edited October 2014 in Working with GS (Mac)

Hi guys,

Here is something I am having an issue with.

I am making a vertical scroller. I have set control camera to the main actor with the scene having 2272px (4x iPhone screen) height and scrolling background. All going well so far. Joystick controlling main actor and I have it set to accelerate slowly downwards while joystick is not touched (i.e. it is falling back down through the level).

My problem is this:

While I want the camera to follow the actor while it is moving upwards through the level, I do not want it to follow while the actor is, for instance, half way up the level and it begins to fall. I want to the actor to just fall to the bottom of the visible screen and die at this point. Currently, if joystick is released and the actor falls, it will continue to fall until back at the very bottom of the scene with the background scrolling back to the bottom.

Any help would be great!

Thanks,
karlpower

Best Answers

  • SocksSocks London, UK.Posts: 12,822
    edited October 2014 Accepted Answer

    @karlpower said:
    Thanks Socks, sounds like it is exactly what I need.

    By any chance could you elaborate a little bit?

    I'm very new to this.

    Well, basically you can do pretty much whatever you need to do to the camera via this method.

    A basic emulation of the Control Camera behaviour as a starting point would be firstly, delete the Control Camera behaviour . . then unlock the main actor (if your game set up allows this, if not then unlock a new actor, and constrain it to your main actor) . . . but assuming you can unlock the main actor . . . place two constrain behaviours into the newly unlocked main actor . . . .

    Constrain Camera Origin X to self.position X - half your scene width.

    Constrain Camera Origin Y to self.position Y - half your scene height.

    You will find Camera Origin under Current scene > Camera (only when the actor is unlocked).

    The Origin is always the lower lefthand corner of the camera view, hence the -half your scene width/height.

    From there onward you can do pretty much what you want, if you you only want the camera to track your hero while his score is lower than 22,000 or a button is pressed or some other condition is met then simply throw the constrains into a rule like you would do with any other actor . . .

    If score < 22,000 then . . .

    Constrain Camera Origin X to self.position X - half your scene width.

    Constrain Camera Origin Y to self.position Y - half your scene height.

    In the Otherwise section. . .
    Do something else, like change the constrain to follow another actor, or maybe just stop or whatever !

    Looking at the 'stop' example . . . . (which would be to simply leave the otherwise section empty)

    So . . . if the score is less that 22,000 the camera follows the actor, if the score goes above 22,000 the camera suddenly stops following the actor and stays were it is.

    Hope that makes some sense.

  • SocksSocks London, UK.Posts: 12,822
    edited October 2014 Accepted Answer

    @karlpower said:
    Is there any way to do this for the bottom of the screen (Y-axis) when the actor might be half way up through the scene. As mentioned previously, I don't want to scroll all the way to the bottom, but rather for the actor to die once he hits the bottom of the screen no matter how far up he may be through the scene. Hope that makes sense. Any help again would be greatly appreciated.

    I'm a little confused by the question, but generally speaking for these kinds of tasks I'd usually just throw up some 'physical' walls/barriers to stop the actor leaving the scene of the crime, just a simple blank actor, with moveable switched off and with a Collide behaviour set to collide with whatever you want to stop leaving the scene (in your case the main actor).

    Once you have placed your 3 actors into position (left, right and bottom), so they are just outside the scene (a 100 pixel wide lefthand barrier would sit on x = -50 for example), then go into layers and place all three on their own new layer, uncheck 'scrollable' so they alway stay where they are regardless of the moving camera.

    So even if you are 30 miles up in the game, the screen edge walls are right there with you.

    It's also not a bad idea to turn visibility off for these walls, you shouldn't need to if they are placed correctly, but it does no harm.

Answers

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

    Any alternative to using control camera? I need to disable when actor falling!

    Place an actor into the scene, unlock it, and you have access to the camera's X, Y, origin, size and so on, use this as your camera control.

  • karlpowerkarlpower Member Posts: 17

    Thanks Socks, sounds like it is exactly what I need.

    By any chance could you elaborate a little bit?

    I'm very new to this.

  • karlpowerkarlpower Member Posts: 17

    Ok perfect, that is exactly what I need I think! thank you very much :smiley:

    One more quick question. I already have set up the following to stop my actor from going outside the side boundaries of the screen and I have it set up for the bottom of the Y-axis.

    Is there any way to do this for the bottom of the screen (Y-axis) when the actor might be half way up through the scene. As mentioned previously, I don't want to scroll all the way to the bottom, but rather for the actor to die once he hits the bottom of the screen no matter how far up he may be through the scene. Hope that makes sense. Any help again would be greatly appreciated.

    Thank you.
    karlpower

  • karlpowerkarlpower Member Posts: 17

    you tha man socks!

    Thank you very much! :smiley: :smiley: :smiley:

Sign In or Register to comment.