Page 1 of 1

zdepth slider idea

PostPosted: Mon Aug 24, 2015 3:36 pm
by JamesLeonardo32
I thought of this idea where you have a zdepth function that can be tuned up or down at any time, like this;

Code: Select all
zdepth+=.1;


Rather than having to manually do a ChangeZdepth action.

Re: zdepth slider idea

PostPosted: Sat Oct 03, 2015 12:05 am
by Zivouhr
Hi James,

I also tried this method through studying the "Make an Actor Fade" tutorial, but am having trouble plugging the code in so it works based on the yscreen position of the characters, as in Streets of Rage or Final Fight games.

Would this code go into Create Actor/script editor:
zdepth+=.1;

And then in draw actor, some how get it to change? Zdepth being assigned as a variable named "zdepthfront" or "zdepthback"?

if(zdepthfront==1)
{
zdepth+=.1;
}


//
if(zdepth+=1)
{
Change ZDepth ("Event Actor", 0.9);
}

else

if(zdepth-=1)
{
Change ZDepth ("Event Actor", 0.1);
}

Just ideas, and the code won't actually work the way I set that up, but I'm guessing it needs some *, < > / symbols in there somehow. Need to do more research on this.

Re: zdepth slider idea

PostPosted: Sun Oct 04, 2015 9:56 pm
by speckford123
Or use the brute force method and put
ChangeZDepth("Event Actor", zdepth);
into a draw actor script, then whenever you change the zdepth variable it will automatically update, hahaha

Re: zdepth slider idea

PostPosted: Thu Oct 08, 2015 4:17 am
by Zivouhr
Interesting method, thanks Speckford. Thanks again for the cool line of script code for the range of an enemy hit zone for a fighting brawler game! That was a great tip.

Here is a really cool and effective zdepth method I discovered thanks to Skydereign recently. Foreground objects appear in front, while background objects appear behind the foreground objects.

Copy/pasted from my other post in game development of City of Rott:

SUCCESSFUL CODE FOR ZDEPTH LAYERING OF ENEMIES AND PLAYER! Streets of Rage or Side Scrolling Brawler Style: 8)
Add code to both enemy (and player) /draw actor/script editor:
Code: Select all
if(yscreen+height/2>collide.yscreen+height/2)  //I only half understand what this does. ;)
{
    ChangeZDepth("Event Actor", yscreen+height/2);   
}
else
if(yscreen+height/2<collide.yscreen+height/2)
{
    ChangeZDepth("Event Actor", yscreen-height/2);  //This is the same as above, but minus after yscreen.
}


Here's a brief "tutorial" example of how it works in action.
zdepthmoveactorTutorial.ged
(7.48 KiB) Downloaded 150 times