Camera following NPC

ABK

Well-known member
Ive got a question about camera, i want to create a stage where you have to escort NPC and protect him from enemies, when he will reach the end of the stage he will collect endlevel item and "level complete" will be shown.Is there any way to automatically scroll the screen when this NPC is moving forward ? So camera is not following players, they have to keep up.If he will get hit by enemies then he will run away and level will exit.
a91cc5eb.gif
 
Well my good friend, right now i’m on Vacation in Greece and i can’t help you too much. At least i can tell you to check  changelevelproperty("cameraxoffset"..
I would say try to add it somehow on your npc and it will do the job. There is also “camerazoffset” ifyou need it.
 
I found and modified this script by bloodbane, it works in level, i change camov entity health to 2 and screen autoscrolls with speed2 , then i spawn camov entiry again at 300 with health 5  and it scrolls  with speed 5 etc. 
This is very nice for different gameplay than usual beatemup.You can control camera through entire level.

Code:
spawn  camov
    flip 1
	health 4
	coords  450  510 
	at  660
Code:
name   camov
type   none


anim spawn
@script
    if(frame==1){
      changelevelproperty("scrollspeed", 0);
    }
@end_script
   delay   2
   offset   1 1
   frame   none
    frame   none

anim idle
@script
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
	 int HP = getentityproperty(self, "health");
    int XPos = openborvariant("xpos");
    int Width = openborvariant("levelwidth");
    int Screen = openborvariant("hResolution");

    if(Dir==1){
      if(XPos < Width-Screen && Dir==1){
        changeopenborvariant("xpos", XPos+HP*0.50);
      } else {
        changelevelproperty("scrollspeed", HP*0.50);
        killentity(self);
      }
    } else if(Dir==0){
      if(XPos > 0){
        changeopenborvariant("xpos", XPos-HP*0.50);
      } else {
        changelevelproperty("scrollspeed", HP*0.50);
        killentity(self);
      }
    }
@end_script
   loop   1
   delay   2
   offset   1 1
   frame   none
   frame   none
IT does not scroll nicely with value like 15 , its quite choppy, any idea how to solve this ?
Ok solved it, just change delay in animations to 2.
How i should modify the script so when i use health 1 then scrollspeed will be 0.1 instead of 1.
--
Solved it ,    changelevelproperty("scrollspeed", HP*0.10); or 0.50 cause with 0.10 its a snail running contest
 
Oh yeah, this is a very nice and useful script by Bloodbane and it can be used for different things in levels related to autoscrolling. I also use this in my DD game already and i totally forgot about it.
 
Back
Top Bottom