PDA

View Full Version : [AS2] Collision Help - glitches and ideas


FluffyPapes
12-24-2008, 07:11 AM
Alright, so I'm making an RPG [shocker?]

Anyways, so as you know, in an RPG, there has to be collisions... like a bajillion of them. So, the first collision is with a wall, [no way ?].

So, my first problem was thinking of how to work the collision. Okay, so, I did this:

if(this.hitTest(_root.wall1))
{
walkSpeed = 0;
runSpeed = 0;
}

So, it got the job done. At least until I wanted to move again. So, I set an else statement so it then looked like

if(this.hitTest(_root.wall1))
{
walkSpeed = 0;
runSpeed = 0;
}else{
walkSpeed = 5;
runSpeed = 8;
}

However, the problem I see is now it's ALWAYS set to 5 walking and 8 running.
What if I try to change it later cause you know, with stats, maybe every 1 stat adds like .2 speed to walking and .3 to running? I don't know yet, but I do know that when I try to change the value, that value is still static.

Any ideas?

Edit:
Also, as for the glitche(s):
I noticed something that was probably not supposed to happen.
I decided to press the Up arrow key while hugging the wall while going sideways. By doing this, it got the player's head going straight through the wall and the player became stuck in an endless loop of collisionness making it constant walkSpeed/runSpeed of 0.

Also any ideas to fix that as well?

orange gold
12-24-2008, 06:29 PM
if(this.hitTest(_root.wall1))
{
walkSpeed = 0;
runSpeed = 0;
}else{
if (running stats == "lvl1") {
walkSpeed = 5;
runSpeed = 8;
}
if (running stats == "lvl2") {
walkSpeed = 10;
run speed = 12;
}
if (running stats == "lvl3") {
walkSpeed = 15;
run speed = 18;
}
if (running stats != "lvl3", "lvl2", "lvl1") { //meaning if its level 4, or 5, or 6, or higher then lvl 3 for insteance if you make the running speed max out at lvl 3 then any lvl above that would still be lvl 3 speed then you say != which means does not equal now you add the lvl max speed
walkSpeed = 15;
run speed = 18;
}
}

FluffyPapes
12-24-2008, 06:33 PM
I guess that's alright to use.

The only problem is that it's not going to be based on levels, it going to be based on the stats of the character. ;[

orange gold
12-24-2008, 06:38 PM
well if their stat in running is 5/100 or whatever then say running stats = "lvl5" then its still doing stats i just changed the var name to lvl5 but you could jsut put running stats = 5

do stuff like this to combine stats

running stats = 0
if (agility stat == 5) {
running stats = running stats +5 // your running stat goes up 1 every 1 agility
}
if (fatigue stat == 20) {
running stats = running stats + 8 //your running stat goes up 2 every 5 fatigue
}
if (acceleration stat == 10) {
running stats = running stats +5 //your running stat goes up 1 every 2 acceleration stats gained
}
//now your running stat is 18 based on what your other stats are
//now you put in the speed codes
if (running stats == 18) {
walkSpeed = 15;
run speed = 23;
}

orange gold
12-24-2008, 07:17 PM
did that help?