Y’all remember that camera in smash bros? I want to make it similar to it, where one person moves away fro other, the camera zooms out, and when moving closer, the camera zooms in, but players are still limited to distance (meaning camera zooming out is limited to where if you keep trying to move away from the other, the camera will automatically move the other closer)
2 Likes
I have the perfect thing for this. give me one sec
1 Like
How to use
- Create a new object to use as your camera
- paste the code inside.
- In each of your players paste the appropriate code.
Let me know if you have any questions!
In the camera, be sure to update its lengths to fit your levels!
Code
Player 1
{"data":{"behavior":{"v":"2","nodes":[{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-630,"y":368,"group":"","id":"2f0504a6657b284f"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-450,"y":304,"group":"","id":"2f0518b351581845","targetId":0,"eName":null,"prop":"x","version":2},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-450,"y":416,"group":"","id":"2f051d970b4fce43","targetId":0,"eName":null,"prop":"y","version":2},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-270,"y":304,"group":"","id":"2f05374250ba7d45","tag":"Player1X:Number","version":2,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-270,"y":432,"group":"","id":"2f053c6f46f3f648","tag":"Player1Y:Number","version":2,"dataType":2}],"links":[{"input_id":"2f0518b351581845i0","output_id":"2f0504a6657b284fo0"},{"input_id":"2f051d970b4fce43i0","output_id":"2f0504a6657b284fo0"},{"input_id":"2f053c6f46f3f648i0","output_id":"2f051d970b4fce43o0"},{"input_id":"2f05374250ba7d45i0","output_id":"2f0518b351581845o0"}]}}}
Player 2
{"data":{"behavior":{"v":"2","nodes":[{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-630,"y":368,"group":"","id":"2f05a5b423c26347"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-450,"y":304,"group":"","id":"2f05a5b4956d1548","targetId":0,"eName":null,"prop":"x","version":2},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-450,"y":416,"group":"","id":"2f05a5b475ece847","targetId":0,"eName":null,"prop":"y","version":2},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-270,"y":304,"group":"","id":"2f05a5b49d30d743","tag":"Player2X:Number","version":2,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-270,"y":432,"group":"","id":"2f05a5b5210f144f","tag":"Player2Y:Number","version":2,"dataType":2}],"links":[{"input_id":"2f05a5b4956d1548i0","output_id":"2f05a5b423c26347o0"},{"input_id":"2f05a5b475ece847i0","output_id":"2f05a5b423c26347o0"},{"input_id":"2f05a5b49d30d743i0","output_id":"2f05a5b4956d1548o0"},{"input_id":"2f05a5b5210f144fi0","output_id":"2f05a5b475ece847o0"}]}}}
Camera
{"data":{"behavior":{"v":"2","nodes":[{"inputCount":0,"outputCount":0,"name":"Camera","behaviorType":"logic.NodeGroup","x":-720,"y":768,"group":"","id":"59c74cf321bb4b46","isMenuItem":false},{"inputCount":6,"outputCount":6,"name":"Camera","behaviorType":"logic.components.View","x":-90,"y":-48,"group":"59c74cf321bb4b46","id":"29c9536c7ad4444f","parallax":100,"scrollX":true,"scrollY":true,"minLeft":-13,"maxRight":80,"top":-9,"bottom":17,"repeatBG":false,"infX":false,"infY":false},{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-540,"y":240,"group":"59c74cf321bb4b46","id":"29cadff170212542"},{"expression":"(A+B)/2","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":2,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":-180,"y":240,"group":"59c74cf321bb4b46","id":"29cba3675fb67343"},{"inputCount":4,"outputCount":2,"name":"Position","behaviorType":"logic.properties.Position","x":90,"y":384,"group":"59c74cf321bb4b46","id":"29cbe11f3e68fb49","pixelUnits":true,"resetVelocity":false},{"inputCount":0,"outputCount":1,"name":"Once","behaviorType":"logic.triggers.Once","x":-720,"y":768,"group":"59c74cf321bb4b46","id":"29d36be2b13bc944","resetOnLevelStart":false},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":-450,"y":816,"group":"59c74cf321bb4b46","id":"29d3b161cfe2e34e","startVal":0,"roundMode":1},{"inputCount":1,"outputCount":1,"name":"Alpha","behaviorType":"logic.properties.Alpha","x":-270,"y":832,"group":"59c74cf321bb4b46","id":"29d3bbfd838cb44f"},{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-630,"y":1120,"group":"59c74cf321bb4b46","id":"2a65fda86117c345"},{"inputCount":1,"outputCount":1,"name":"Extractor","behaviorType":"logic.properties.Extractor","x":-450,"y":1120,"group":"59c74cf321bb4b46","id":"2a660379a4bf5b4a","targetId":0,"eName":null,"prop":"y","version":2},{"gateVal":64,"mode":"less than or equal to","inputCount":2,"outputCount":2,"name":"Filter","behaviorType":"logic.logic.Filter2","x":-270,"y":1104,"group":"59c74cf321bb4b46","id":"2a66235b0d81de48"},{"inputCount":3,"outputCount":1,"name":"Number","behaviorType":"logic.logic.Value","x":-90,"y":1104,"group":"59c74cf321bb4b46","id":"2a66a73189216748","startVal":5,"tag":"","roundMode":1},{"inputCount":4,"outputCount":2,"name":"Position","behaviorType":"logic.properties.Position","x":90,"y":1088,"group":"59c74cf321bb4b46","id":"2a66d26ea49fa34e","pixelUnits":false,"resetVelocity":true},{"inputCount":0,"outputCount":1,"name":"Always","behaviorType":"logic.triggers.Always","x":-540,"y":496,"group":"59c74cf321bb4b46","id":"2a761509ef8ba146"},{"expression":"(A+B)/2","default0":0,"default1":0,"default2":0,"default3":0,"default4":0,"default5":0,"params":2,"version":2,"tag":"","inputCount":3,"outputCount":1,"name":"Expression","behaviorType":"logic.logic.Expression","x":-180,"y":496,"group":"59c74cf321bb4b46","id":"2a776a8c08b0f548"},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-360,"y":464,"group":"59c74cf321bb4b46","id":"2f06184ffe5f7f46","tag":"Player1Y:Number","version":2,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-360,"y":576,"group":"59c74cf321bb4b46","id":"2f06201398746347","tag":"Player2Y:Number","version":2,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-360,"y":176,"group":"59c74cf321bb4b46","id":"2f20f84750200b4a","tag":"Player1X:Number","version":2,"dataType":2},{"inputCount":3,"outputCount":1,"name":"Global","behaviorType":"logic.logic.Global","x":-360,"y":288,"group":"59c74cf321bb4b46","id":"2f20fe163dc9d14e","tag":"Player2X:Number","version":2,"dataType":2}],"links":[{"input_id":"2f20f84750200b4ai1","output_id":"29cadff170212542o0"},{"input_id":"29cba3675fb67343i2","output_id":"29cadff170212542o0"},{"input_id":"2f20fe163dc9d14ei1","output_id":"29cadff170212542o0"},{"input_id":"29cbe11f3e68fb49i0","output_id":"29cba3675fb67343o0"},{"input_id":"29d3b161cfe2e34ei1","output_id":"29d36be2b13bc944o0"},{"input_id":"29d3bbfd838cb44fi0","output_id":"29d3b161cfe2e34eo0"},{"input_id":"2a660379a4bf5b4ai0","output_id":"2a65fda86117c345o0"},{"input_id":"2a66235b0d81de48i1","output_id":"2a660379a4bf5b4ao0"},{"input_id":"2a66a73189216748i1","output_id":"2a66235b0d81de48o0"},{"input_id":"2a66d26ea49fa34ei1","output_id":"2a66a73189216748o0"},{"input_id":"2f06184ffe5f7f46i1","output_id":"2a761509ef8ba146o0"},{"input_id":"2a776a8c08b0f548i2","output_id":"2a761509ef8ba146o0"},{"input_id":"2f06201398746347i1","output_id":"2a761509ef8ba146o0"},{"input_id":"29cbe11f3e68fb49i1","output_id":"2a776a8c08b0f548o0"},{"input_id":"2a776a8c08b0f548i0","output_id":"2f06184ffe5f7f46o0"},{"input_id":"2a776a8c08b0f548i1","output_id":"2f06201398746347o0"},{"input_id":"29cba3675fb67343i0","output_id":"2f20f84750200b4ao0"},{"input_id":"29cba3675fb67343i1","output_id":"2f20fe163dc9d14eo0"}]}}}
2 Likes
@Endermanjeff
Did it work?
1 Like
Where would I put the camera variable?
1 Like
Its already inside of the camera code i gave you.
Let me know if its not there
yes, that should be right. just make sure you put the player 2 code inside your player 2 object. (P.S this is made for local multiplayer)
1 Like
This is perfect! thanks for the help
1 Like
yw, please feel free to ask for help and ping me anytime
1 Like
There’s only one problem: The players aren’t able to touch each other (sorry for ping)
1 Like
MAke sure your camera has “Solid” attribute “disabled”
1 Like
and your fine, you can ping me whenever
1 Like
Aight. Thanks. I’ll make sure to credit you in the game
2 Likes
Yw, I will help anytime
1 Like
I do have this example:
2 point Camera Zoom - Flowlab Game Creator
2 Likes