Character walks by a mirror (solved)

Started by Timosity, Wed 02/07/2003 09:52:51

Previous topic - Next topic

Timosity

OK, I have a large mirror on one screen the player passes, and i need to have him reflected.

I have created another character with flipped forward and backward views so he has a mirrored effect.

I've started with this simple test script just to so what happens.

character LAZ being the player character

 // script for room: Repeatedly execute
if (character[LAZ].x<68){ // character not infront of mirror
character[LMI].x=300;
character[LMI].y=120;  // character hidden behind walkbehind area
}
else{
character[LMI].x=character[LAZ].x;
character[LMI].y=character[LAZ].y-20;  
}

What happens is the character LMI stays 20 pixels in front, but the character doesn't walk, it just stands in the same position and drags along.

how do I get him to walk, as these lines

character[LMI].x=character[LAZ].x;
character[LMI].y=character[LAZ].y-20;   //temp y position till i figure out NPC walking

just place the character in the right places.(it's like he's just gliding or being dragged [he is also on a walkable area])

also I've been trying to figure out (with no luck) how set the right Y position.

eg. when the character walks towards the mirror I need the Y value to Move closer to zero and when I walk away I need the Y value to Move further negative, [so he looks like he's walking toward or away from the mirror] the X value is easy as it is just the same as the player character.

I know it can be done, I'll just keep experimenting, but I'll appreciate any help, Thanks


SSH

#1
Firstly, its funny how something quite advanced like this ends up in the Beginners Tech forum, and lots of beginners post RTFM questions in the Tech forum...!

You will probably need a scaling factor in the equation for y. Here scale is that factor (experiment!) and mirrorbase is the bottom of the mirror's y co-ord.

laz_dist_from_mirror=character[LAZ].y-mirrorbase;
lmi_dist_from_mirror=laz_dist_from_mirror/scale;
character[LMI].y=mirrorbase-lmi_dist_from_mirror;

Also, for animation you could try:

if (character[LAZ].loop != last_laz_loop) {
 AnimateCharacter(LMI, character[LAZ].loop, speed_of_laz_anim, 1);
}
last_laz_loop = character[LAZ].loop ;

It would be handy if one could just write
character[LMI].loop=character[LAZ].loop;
character[LMI].frame=character[LAZ].frame;

but loop and frame are RO, apparently

Hope it helps!
12

Timosity

Thanks SuperSH, that's given me some ideas on the situation, I'll let you know how it goes, meanwhile I must sleep, then go to work.

I usually post stuff in the beginners cause I always think (or hope) that what I'm trying to do has a simple solution that I have just missed somewhere.

Couple of weeks ago, I thought it would be simple to animate a gui button, boy was I wrong.

Scorpiorus

Quotecharacter[LMI].loop=character[LAZ].loop;
character[LMI].frame=character[LAZ].frame;
hehe, you can actually. This is how I usually do in the similar situations. Yes, it's read-only but it's because to prevent mess while he is animating(walking) but when the char stands that's ok. (the same stuff as for character[].x, character[].y vars). You shouldn't do it normally.. but in particular ways (like that) it's is a good workaround I think.

-Cheers

Timosity

Thanks SSH, worked perfectly,

int mirrorbase=132;
int laz_dist_from_mirror;
int lmi_dist_from_mirror;
int scale=3;

 // script for room: Repeatedly execute
character[LMI].x=character[LAZ].x;

laz_dist_from_mirror=character[LAZ].y-mirrorbase;
lmi_dist_from_mirror=laz_dist_from_mirror/scale;
character[LMI].y=mirrorbase-lmi_dist_from_mirror;


character[LMI].loop=character[LAZ].loop;
character[LMI].frame=character[LAZ].frame;

Also Scorpiorus is right, that loop, frame thing works exactly how I wanted it, thanks to both of you for replying.

All I had to do was change LMI views so that forward was backward and vice-versa, also for the side view, I had to have it so eg. when the left foot was forward on LAZ, the right foot had to be forward on LMI,

I could swear there was actually a fully functional mirror in every aspect on the screen, Thanks again guys

very much appreciated

~Tim

SSH

#5
Quote from: Tìmosíty link=board=6;threadid=7022;
start=0#msg85993 date=1057240695

I could swear there was actually a fully functional mirror in every aspect on the screen
It reflected your face as well? Did you link it with your webcam or something?  ;)
12

Timosity

hehe,

No, I just glued some small mirror pieces to the screen, works like a charm

SMF spam blocked by CleanTalk