Multi-Player game Camera problem

Hello guys! Recently i've been trying to achieve super smash bros like camera movement.(when players are close to each other camera is getting closer) So i created an atribute distance wich calculates the distance beetwen the players. I've tried to constrain it to scene size but it didn't work... I also tried creating a rule wich says (if atribute "distance" is < 500 change atribute camera size to...) it kinda worked but its not what im trying to achieve. It's hard to describe the effect so maybe just wach a video? ()Any ideas? :(

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    Here's a really crude and first attempt at it. If you think it's a good starting point you'll have to add rules to stop the players moving out of scene so that when the camera zooms out you don't see the black scene outside of the background actor.

    Move both actors around the scene with the keyboard. One actor is controlled with A,W,S,D keys and the other is controlled with the cursor key.

    There's code on the background actor (instance version, not prototype).

    The blue actor has a follow camera behavior on it but after attaching it to this post I noticed it's not needed as the background actor constrains the camera to blue actors position.

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    You may want to play around with the sizing of the camera too. I just took the distance between the two and doubled the camera size, but this sometimes causes the red actor to be right on the edge of the view. Try trebling the camera width instead.

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    One last thing. If I were to attempt this again I'd have a 3rd hidden actor constrained to the centre of actor A and B and have the camera centre constrained to the 3rd actors position. You have the x and y position of actors A and B so it shouldn't be hard to come up with a formula to find the centre point between the two.

    Double camera width would work well for this.

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2016

    @KevinCross said:
    You have the x and y position of actors A and B so it shouldn't be hard to come up with a formula to find the centre point between the two.

    X centre =(Ax+Bx)/2
    Y centre =(Ay+By)/2

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    @Socks said:

    @KevinCross said:
    You have the x and y position of actors A and B so it shouldn't be hard to come up with a formula to find the centre point between the two.

    X centre =(Ax+Bx)/2
    Y centre =(Ay+By)/2

    Awesome, thanks. I was walking home so too tired to think. Probably wouldn't have come up with that though. I would have probably created half a dozen more attributes a few more actors and used tables to work out the centre point >.<

  • MaksRzontkowskiMaksRzontkowski Member Posts: 2

    @KevinCross Thank you so much! Would you mind if i ask you for a screenshot of the prototype/instance version from autozoom.zip I can't open it :/

Sign In or Register to comment.