Page 1 of 1

hitting things

PostPosted: Fri Mar 03, 2006 10:51 pm
by The achievement
Hi guys again, i know this sounds strange but i just found out that you can put that caveman character person in your game(DER) and he has this red club right, how do i make him hit stuff with it. i think this is a key down event.. Help! if you want to.

PostPosted: Fri Mar 03, 2006 11:10 pm
by Game A Gogo
1.Create a var:Direction
2 a.on key down event: right ALT (if using the game on windows)
2 b.then a script:
Code: Select all
if (Direction==1)
{
      (Change anymation to left hitting club);
}
else if (Direction==0)
{
      (Change the animation to right hitting club)
}

3 a.on animation finish: left hitting club
3 b.then change the animation:stop left
4 a.on animation finish: right hitting club
4 b. then change the animation to stop right
5 a. key down event: Left
5 b.Then a script:
Code: Select all
Direction=1;

6 a.On Key down event:Right
6 b.Then a script:
Code: Select all
Direction=0;


Thats all, but that only for making the animation change to the club swinging.

Ill try to figure out the good code for making it actualy hit the enemy, that help me too!

PostPosted: Fri Mar 03, 2006 11:54 pm
by DilloDude
What I do, when you have a sword to swing at an enemy, is create a separate actor 'sword', and have animtions for facing each direction and swinging each direction. Make its parent your character, or say x = player.x, y=player.y or something. This mkes it follow 'player', but it is not a parent so you can have a lesser z-depth. Have a variable for players facing direction, and on sword's drw actor, depending on direction, change animation. On keydown for the key you want to use to swing, set a 'swing' variable to 1. Back in the draw actor, If swing, if dir(your direction variable) == value for left, if animindex !=(not equal to) the animindex for swingleft animation, change animation to swing left. After ending past the if dir==left, have else if dir== right, and do a similar thing. Now go back past the if swing, and have else, and find the direction and change the animation for not moving like you had before.
Now add animation finish event for sword, and have script editor, and swing = 0. Now, add on enemy, collision with sword, if swing, do action. An enemy will perform this action when it hits your sword and it is swinging.
If you need me to explain anything better, just ask.

PostPosted: Fri Mar 03, 2006 11:57 pm
by The achievement
Im stumped, so i what do i do first?? can you tell me step by step? thank you!

PostPosted: Sat Mar 04, 2006 12:44 am
by The achievement
ok whenever i press right alt the club goes in back of me? im screwed up. :(

PostPosted: Sat Mar 04, 2006 12:48 am
by The achievement
lol im being a nagggg but what do i do first, cause Game a gogo i think your telling me just to do it on my main actor, then dillo dude is tellin me to create a sword actor. im so confused :? :? :?

PostPosted: Sat Mar 04, 2006 1:28 am
by DilloDude

PostPosted: Sat Mar 04, 2006 10:52 pm
by The achievement
ya but i wanna know how i swing the dang club first, i dont want to go right to hitting eniemies without swinging the club, i dont think you can even swing the club on the char :(

PostPosted: Sun Mar 05, 2006 1:24 am
by Game A Gogo
yes u can, my method is adding the swinging club animation.
i know how to do the enemy healt go down when his hit, but i dont have enought time to explain.

Note:
Im not sure, but if u use only one actor, it will take less memory then two actor. This is not proved, just use the method u prefer.

PostPosted: Sun Mar 05, 2006 1:54 am
by The achievement
ya but how do i create a variable Direction? Im sorry for so many questions!

PostPosted: Sun Mar 05, 2006 5:16 am
by DilloDude
In the script editor, at the bottom there are a few buttons. There is actors, variables and functions, and variables. Choose variables, then add. Then fill out the fields:
Name: what you want the variable to be called- var, enemyWalk, etc.
Integer/Real/String: the type of number: integers are whole numbers including negatives: -3, -1, 0, 2, 3060 etc.
Real numbers include decimals: 1.5, -6.7896538, 2.001 etc.
Strings are lines of characters, such as text: Hello_?, Password etc.

Global/Actor: a global variable is one that applies to the whole game, and each actor can acces it directly.
An actor variable is a variable applied to every actor, thus each actor has thier own copy of that variable.
in a particular actor's script editor, it's actor variable can be accesed by the variable name. To access another actor's actor variable,]
you must put actor.variable. examples: x, y, (view.x, player.y) actor1.health etc.
Array: an array is a variable with multiple values, accesed by a number in square brackets []. The array size is the number of
values for the array. For example, an array variable 'var' with array size 4:
Code: Select all
var[0]=2;
var[1]=0;
var[2]=72;
var[3]=9;

Save group: put a name here if you want to save the variable, and put each variable you want to save in the same save group.
You may want to save things like highscore, for example. If your variable does not need to be saved, don't enter a save group name.

PostPosted: Sun Mar 05, 2006 5:57 pm
by The achievement
ya but my enemy doesent have health, i just want to swing at him and make him die. i know thats a hole other code, and if i get the club swinging,i can do everything from there like the collision, all i want to know is how do i just get the club swinging.