How to trigger object animation by checking view and/or frame? :)

Started by KyriakosCH, Fri 09/09/2016 00:01:56

Previous topic - Next topic

KyriakosCH

Hi, basically i want to control where an object moves, and not have it use one continuous animation but go from part of the room to another using loops depending on the immediately previous part it was in & the direction.

What is the easiest way to do this?

Currently i would need 7 different runs for each of the 8 different positions it can be in (8th cancels cause it is already there :) ).

For example, if the object is in position A, which has to the left of it position B and even more to the left position C, i want to set it so that if the object is ordered to go to C it will play animation both for A-->B and B-->C. And so on.
This is the Way - A dark allegory. My Twitter!  My Youtube!

Mandle

I would use a variable to keep track of what position the object is currently in and use different view loop numbers of the animations to correspond with these:

For example: Moving from position 1 to 2 uses loop 1...

KyriakosCH

Thanks :D

Of the simple scripting, variables are the only thing i haven't yet looked into...

Although in the case of this object i think i might also be able to use regions, if i tie it to the player (or even if not?)

I am thinking that if there are no more than three bordering regions (and usually only two, and obviously just one on each edge) it will take a small number of cancelling/altering region events for this to work. Eg in linear (just one direction) stuff it would only need 2 states for each region, which isn't overkill given i just need 8 regions anyway.

I am sure the variable thing would have been far more elegant, but i still don't know how to script it :D
This is the Way - A dark allegory. My Twitter!  My Youtube!

Snarky

Trying to code without variables is like trying to write without consonants. You're not going to get very far.

KyriakosCH

^But how far can you get in being helpful in a thread by just being snarky? :=
This is the Way - A dark allegory. My Twitter!  My Youtube!

Snarky

How helpful it is is entirely up to you. If you take my advice, sit down and learn how to use variables to solve what seems like a simple problem, you'll have acquired a powerful new skill that will be of great value to you in developing the game. If you don't, my comment will not have been helpful at all. I'm fine with that.

KyriakosCH

Come on, that is not an 'advice'; if anything it is a platitude and it was already noted that variables are the only basic thing in scripting i haven't looked into. I should note you seem to be deliberately snarky (ok, it is your handle here as well, but still) :P
This is the Way - A dark allegory. My Twitter!  My Youtube!

Slasher

On the contrary, Snarky's advice is an advice you should embrace.

If you don't know anything about variables it's may to be hard to understand the concept.

A variable could be a boolean where the boolean can be set true or false and can be used to set conditions true or false for running events etc....

There are other types of variables. Check them out to get a better understanding.

Believe me, it pays to learn...and it's not that hard (nod)

Code: ags

{
if(thisboolean==true)
// Do this
else
//Do this instead
}


A certain known member here once told me: "I'll give you the tools to make it but you'll have to make it yourself."



KyriakosCH

Thanks, i will have to learn scripting it, although the concept is known. Even the game i am making is (to a degree) about spirals and math (nod)
This is the Way - A dark allegory. My Twitter!  My Youtube!

Mandle

Quote from: KyriakosCH on Fri 09/09/2016 11:24:10
I am thinking that if there are no more than three bordering regions (and usually only two, and obviously just one on each edge) it will take a small number of cancelling/altering region events for this to work. Eg in linear (just one direction) stuff it would only need 2 states for each region, which isn't overkill given i just need 8 regions anyway.

I am sure the variable thing would have been far more elegant, but i still don't know how to script it :D

What you would be doing then is using the regions as surrogate variables: I also once used a character's Transparency set to 1% as a check to tell the game what to do, because I couldn't get variables working properly:

Your best bet for a small game is to define your variables manually in the Global Variable menu in AGS: Just right click on the left-hand empty field and AGS will lead you through all the steps to create a new variable:

This variable will now work anywhere within your game in simple "if-check" statements:

[pseudo-code]
Code: ags

   AntmoveA=Random(2)+1; (The +1 is just so you have a number of 1-3 instead of 0-2)
     if (AntmoveA==1)
       {
        cAnt.Move(126, 450, etc etc....
        cAnt.Loop=2 (or SetLoop or whatever it is...I usually just look at the autofill choices when not sure)
        Then a line here to start the animation...
       }

[/pseudo-code]

And, if some people seem less than helpful in your opinion: They are not replying to troll you:

They are taking the time to reply to your problem with advice to not spoon-feed you the code you need, but to point you in the right direction so that you can do the same task by yourself next time without needing a thread asking how to do it...

Remember the old chestnut:

"Make a fire for a man and he will be warm for one night...Set him on fire and he will be warm for the rest of his life..."

KyriakosCH

This is the Way - A dark allegory. My Twitter!  My Youtube!

KyriakosCH

Ok, in the end i too joined the dark side, and now script with variables.

Thanks for the help 8-)
This is the Way - A dark allegory. My Twitter!  My Youtube!

Cassiebsg

It's nice you joined the dark side, cause I seriously doubt you could have made a game with using them at one point or another... (nod) and no, interactive fiction doesn't count as game. (laugh)
There are those who believe that life here began out there...

Mandle

Quote from: KyriakosCH on Sat 10/09/2016 17:49:26
Ok, in the end i too joined the dark side, and now script with variables.

If you continue on with making games I hope you see this post again 2-3 years from now...

You will have such a laugh!

Snarky

Great. And you were able to solve your original problem?

KyriakosCH

This is the Way - A dark allegory. My Twitter!  My Youtube!

Mandle

Quote from: KyriakosCH on Sun 11/09/2016 10:34:00
Yes.

Now the thing moves fine on its own 8-0

And maybe a quiet "thank you" to Snarky for the very gentle kick in the ass?


SMF spam blocked by CleanTalk