characters dying in an area and animation

Started by Blondbraid, Thu 20/08/2015 19:33:04

Previous topic - Next topic

Blondbraid

I'm making a game where the player can die if they walk into the wrong area.
What I need help with is:
1. How do I make the player character die when they walk onto a walkable area? Or rather, which commands shall I use to play a certain animation when the character walks onto the walkable area in question?
2. How shall I do if i want to play different loops of animation depending on which direction the character is facing, example: a character facing right will die facing right and not any other direction?


DBoyWheeler

Well, for number 1... might want to use a Region, or perhaps a Hotspot, instead of a Walkable Area.

For number 2... maybe create a separate "View" called "vDeathView" (or whatever you want to call it), and have each direction having its own death animations.  (Like one of death facing down, one facing right, etc).

Blondbraid

#2
QuoteFor number 2... maybe create a separate "View" called "vDeathView" (or whatever you want to call it), and have each direction having its own death animations.  (Like one of death facing down, one facing right, etc).
Yes, I have already created a separate view, but how do I make the loop change depending on the direction of the character? I want to avoid having a character walking towards the right direction suddenly die facing the left direction. ???
Using regions solved the first problem though. (nod)


selmiak

if you are sure the character is still walking (nonblocking) when you want to play the death sequence you could check for cEgo.Loop, make him stop and animate the same loop on a different view.
Or make the place you want to play the death sequence on only accessible from one side and play the resulting animation. Then you only have to animate it once ;)

Snarky

(I only have access to the 3.2.1 manual right now, and I know the API for facing different directions was updated in 3.3, so this could be slightly out of date, but should hopefully still work.)

This is what the manual recommends to run a custom animation:

Code: ags
cEgo.LockView(12);
cEgo.Animate(0, 0, eOnce, eBlock, eForwards);
cEgo.UnlockView();


The first argument to the animate function is the animation loop of the view. This corresponds to the direction the character is facing, so instead of passing 0 (which means up/north in AGS), use the character's current loop:

cEgo.Animate(cEgo.Loop, 0, eOnce, eBlock, eForwards);


This assumes you have provided loops for all the directions your character might face.

Blondbraid

Everything appears to work as intended, thank you for your help!


SMF spam blocked by CleanTalk