DCurrent / openbor

OpenBOR is the ultimate 2D side scrolling engine for beat em' ups, shooters, and more!
http://www.chronocrash.com
BSD 3-Clause "New" or "Revised" License
894 stars 119 forks source link

Changing Cameratype by script #282

Closed dbaldan closed 8 months ago

dbaldan commented 11 months ago

Is your feature request related to a problem? Please describe. Cameratype - which allows the camera to follow the hightest player - can only be changed by native method (IOW, setting it in stage header) but its not open to script.

This creates an issue when you have a stage with a slope, where you start on the highter point at left and move down to a lower area, like this: https://imgur.com/a/e6BlGZN image

Because the camera will follow the player too much on the lower area, causing motion sickness. Specially when you have a wide (z-depht) stage, where the character can move up and down a lot.

Describe the solution you'd like

Being able to change it by script like this: changelevelproperty("cameratype", 0);

Describe alternatives you've considered

My current solution was setting the camera offset to a lower point changelevelproperty("camerazoffset", 250);

But this removes the ability of the camera to move when the character moves up and down on the stage

Additional context We could have an extra option in camera type which allows the camera to follow the player only on one axis, instead on all 3. For example, we could have the camera to move up and dow if the player moves up and down in Z axis, but won't follow it if he jumps (ignoring the Y axis in this case)

dbaldan commented 11 months ago

Added a suggestion about an extra option in camera type.

magggas commented 9 months ago

Actually you can do all this with script already anyway. Back in the day when i started my DD game i also asked about this feature and also other people too but i think they never added because it already can be done what you are asking.

Anyway, Bloodbane back then showed me this little trick he used on his contra game, which is to add a small anim script on idle that includes this: changelevelproperty("camerazoffset", -100 - y) or changelevelproperty("camerazoffset", -100 - base).

Here are the small functions i made for my game with it:

void camera() { // Spawn and bind other entity void self = getlocalvar("self"); void P1 = getplayerproperty(0, "entity"); void P2 = getplayerproperty(1, "entity"); void vAniID1 = getentityproperty(P1,"animationID"); void vAniID2 = getentityproperty(P2,"animationID"); int Offset1 = getentityproperty(P1,"base"); int Offset2 = getentityproperty(P2,"base"); int Offset3 = getentityproperty(P1,"a");

if(P2){ changelevelproperty("camerazoffset", -100 - Offset2); }

if(P1){ changelevelproperty("camerazoffset", -100 - Offset1); }

if(P1 != NULL() && getentityproperty(P1,"exists") && P2 != NULL() && getentityproperty(P2,"exists") && vAniID1 == openborconstant("ANI_IDLE") || vAniID1 == openborconstant("ANI_JUMPLAND")){ changelevelproperty("camerazoffset", -100 - Offset1); }else if(P1 != NULL() && getentityproperty(P1,"exists") && P2 != NULL() && getentityproperty(P2,"exists") && vAniID1 == openborconstant("ANI_FOLLOW22") || vAniID1 == openborconstant("ANI_FOLLOW23")){ changelevelproperty("camerazoffset", -100 - Offset3); } }

void camera2() { // Spawn and bind other entity void P1 = getplayerproperty(0, "entity"); void P2 = getplayerproperty(1, "entity"); int Offset1 = getentityproperty(P1,"a"); int Offset2 = getentityproperty(P2,"a");

if(P2){ changelevelproperty("camerazoffset", -100 - Offset2); }else if(P2 && P1 != NULL() && getentityproperty(P1,"exists")){ changelevelproperty("scrollspeed", 1); }

if(P1){ changelevelproperty("camerazoffset", -100 - Offset1); }else if(P1 && P2 != NULL() && getentityproperty(P2,"exists")){ changelevelproperty("camerazoffset", -100 - Offset1); } }

The "camera" function (first one) is checking the player's base, so it only moves on Z and not on Y when player jumps. And i only had to add it to idle and jumpland animation for my use. The second function "camera2 is checking player's Y and i was using it on my clibing animations so the camera follows up/down. Now my scripts are a bit poorly made but ok for my purpose but the idea is with the changelevelproperty("camerazoffset", -100 - Y); or changelevelproperty("camerazoffset", -100 - base); you can do nice little functions or parts of a mainscript which will take care of the camera problem. Also if you only need this for only just one spot in only one stage you can just place a blank entity on that spot with the script on it so that you will not need to having it on players all time.

dbaldan commented 9 months ago

@magggas thank you.

DCurrent commented 8 months ago

Closing since specific issue is resolved. Development code is opening all level properties, including camera switches.