00:00
00:00
Newgrounds Background Image Theme

ozziel94 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Can someone help with camera ai?

349 Views | 1 Reply
New Topic Respond to this Topic

Can someone help with camera ai? 2014-12-05 22:22:59


Hi guys thanks for taking the time to read this! so.. I'm making this game and for one of the parts there's going to be an epic DBZ style energy duel. nothing too fancy.

essentially all it is is two characters with a line and energy ball between them.

>=good guy
<=bad guy
() ball

badly drawn ascii art version of my stage

>_____()_____<

so on mouse up the ball moves to the right towards the bad dude 5 pixels, otherwise it just constantly moves left 1 per frame.

anyway, I'm using the good old as2 oreilly vcam as the director for this duel. so it's coded so it stays centered on the ball...

now I'm also trying to make it so when either of the characters are out of the stage it zooms out and zooms back in when they are both on stage to mimic camera movement in an otherwise dull duel.

anyway I'm trying to make it smoother then just _xscale-- etc. so here is what the code looks like on my camera.

onClipEvent (load) {
this._x = _root.Duel.Ball._x;
this._y = _root.Duel.Ball._y;
HUDScale = 100;
MaxHUD = 100;
}
onClipEvent (enterFrame) {

this._x = _root.Outtro.Duel.Ball._x;
this._y = _root.Outtro.Duel.Ball._y;
this._xscale = HUDScale;
this._yscale = HUDScale;
if (HUDScale < 100)
{
HUDScale += Math.round((MaxHUD - HUDScale) / 4);
}
if (!this.hitTest(_root.Outtro.Duel.GoodGuy) || !this.hitTest(_root.Outtro.Duel.BadGuy))
{
MaxHUD++;
}
else if (this.hitTest(_root.Outtro.Duel.GoodGuy) && this.hitTest(_root.Outtro.Duel.BadGuy))
{
MaxHUD--;
}
}

so I guess what I am trying to ask(in a very overly complicated way haha ) is how you math pros would go about coding the zoom part.

on mouse up(on my guy's code) it takes 5 away from HUDScale, then the vcam fixes the zoom-in(my sloppy attempt at a camera rumble)

that worked fine untill i tried keeping the two duelists on screen with MaxHUD. but now it seems fucked up big time. I know it's something to do with how I coded this part but I'm getting serious brainfarts right now.

this is the spot in the code I'm messing up

HUDScale += Math.round((MaxHUD - HUDScale) / 4);

any help would be greatly appreciated!

Response to Can someone help with camera ai? 2014-12-05 22:46:16


Nvm guys I just needed to take a step back from my code for a bit. this was the problem

if (HUDScale < 100)

forgot to make the 100 MaxHUD haha