Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




[F8] Collision Detection Quesetion For Avoider Game



Im working on a sequel to my avoider game, for anti cheat i want to draw lines from the last position of the mouse to the current position. I have that part working, but im not sure how to do the collision part, bitmap wont work will it? because i have my ground animated so it is constantly changing.



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-24-2007, 03:33 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Game Collision Detection Please Help
hello,
I have to make a flash game for one of my assignments we have been told that we can take an already made flash game as we havent been taught actionscript and change the images, but i cant find any that i want to use and decided to make my own game,

i have a person who can go up down left right and when he hits the walls he stops, but he can only go really slow, i need to find a way to make him go a bit faster. Also the man has to collect certain objects that move along from the right and avoid certain objects (do you know what i mean?) and these either add points or take away points / lives and i dont know how to do this

please please help
thank you very much
Richard

Collision Detection In A Game
Hi guys. Need help with a small project im working on.
Basically im trying to check for collisions succesfully and make the character move to a certain position when colliding with something.

Link: http://truimagz.com/hosting/Public/testarea.html
Link to fla: http://truimagz.com/hosting/Public/testarea.fla

If you need to check the collisions on th fla, go to the background mc and then to the 2nd frame and check the as for the 2nd frame. I have had like 100 attempts to get it working so any help would be sooo greatfully appreciated.

All i need isfor someone to look at the script and tell me what im doing wrong.

Thanks.

Collision Detection (racing Game)
Morning all!

I'm developing a basic car racing game. I've made a start by using a ready-made Actionscript applied to the movieclip "auto" (the car). All works fine and well.


Code:
//
// ---------------------------------------
// 2D Car game. Created on 28/10/2002
// ---------------------------------------
// By Laurent van Dommelen
// contact: lvdingen@hotmail.com
// It's free to use, but please contact me.
// ---------------------------------------
//
onClipEvent (load) {
// Edit these parameters, max speed forward, and max speed backwards
maxspeed = 7;
maxnegspeed = -6;
// Init vars
speed = 0;
// Definition of the move function, it moves the car around the screen
function move(afstand) {
draaihoek = (_rotation/180)*Math.PI;
_x += afstand*Math.sin(draaihoek);
_y += -afstand*Math.cos(draaihoek);
return afstand;
}
}
onClipEvent (enterFrame) {
// If UP key pressed, raise speed by 0.1
if (Key.isDown(Key.UP)) {
if (speed<maxspeed) {
speed += 0.9;
}
} else {
// If up key not pressed nor the down key... slowly lower speed
if (Key.isDown(Key.DOWN) == false) {
speed *= 0.9;
if (speed<0.2 and speed>-0.2) {
speed = 0;
}
}
}
// If DOWN key pressed; brake or reverse te car
if (Key.isDown(Key.DOWN)) {
if (speed>maxnegspeed) {
speed -= 0.4;
}
}
// Steer left
if (Key.isDown(Key.LEFT)) {
_rotation -= speed/1;
}
// Steer right
if (Key.isDown(Key.RIGHT)) {
_rotation += speed/1;
}
//
// This calls the move funtion which makes the car
// actually move
//
move(speed);
// Returning rounded speed for speed counter
_root.speed = Math.round(speed);
}


However, I'm having a bit of trouble with collision detection. The game will have two cars, and so I need to detect collisions between the two vehicles, but also on the sides of the track and other obstacles (will just be other movie clips or graphics). What basic Actionscript can I add to the code above (if indeed it is to be added to the Car code) to detect a collision between the movie clips, and to make the car bounce back?

Sorry if that's a really lame request!! Thanks for any help offered.

Collision Detection Blasterball Game
I'm trying to make a game similar to araknoid/blasterball/breakout.
Where can i find good tutorials for beginners?

Collision Detection (Walls In A Game)
Hi Guys, I've got a man walking on top of an image of an apartment, but at the moment he can walk anywhere (controlled by the keyboard).

I have added a layer, called 'Walls', this contains transparent images mapped around the walls, each part of the wall is a movie clip called 'walls'. When the moving man hits a part of the wall, i want him to stop and not be able to go through the wall.

The flash file is at: http://www.dhardy.co.uk/Walking.fla (1.4MB).

Thanks in advance! Dave.

Problem With Collision Detection In A Game
Hi, I'm pretty useless with Flash but I have to make a top-down (overhead view) maze-game for University. I'm trying to put collision detection in at the moment. I have collision detection which works on the walls of the room, but the separate code I have for the objects in the room doesn't work - A tutor applied the following code to one object which did work, and then left me to apply it to all other objects and went home for the day.

Is anyone able to explain why the following code (which was working when it was applied to one object) stopped working (including on the original movie clip) when I applied it to the actions of the other movie clips? I tried deleting this text from all other objects/movie clips but the one it originally worked on and it still didn't work - now all of my objects can be walked through...


Here is the code I used:






onClipEvent (enterFrame) {
if (this.hitTest(_root.man.hitArea)) {
if (_root.man.direction == "left") {
_root.man.disableLeftObject = true;
//_root.bg._x -= 20;
}
if (_root.man.direction == "right") {
_root.man.disableRightObject = true;
//_root.bg._x += 20;
}
if (_root.man.direction == "up") {
_root.man.disableUpObject = true;
//_root.bg._y -= 20;
}
if (_root.man.direction == "down") {
_root.man.disableDownObject = true;
//_root.bg._y += 20;
}
} else {
_root.man.disableLeftObject = false;
_root.man.disableRightObject = false;
_root.man.disableUpObject = false;
_root.man.disableDownObject = false;
}
}



If you need any of my other code in order to determine the problem I'll post some of that too.

Thanks in advance.

Problem With Collision Detection In A Game
Hi I'm pretty useless with Flash but I have to make a game for University. A tutor applied the following code to one object which worked and then left me to apply it to all other objects and went home for the day.

Is anyone able to explain why the following code (which was working when it was applied to one object) stopped working (including on the original movie clip) when I applied it to the actions of the other movie clips? I tried deleting this text from all other objects/movie clips but the one it originally worked on and it still didn't work - all of my objects can be walked through...


Here is the code I used:






onClipEvent (enterFrame) {
if (this.hitTest(_root.man.hitArea)) {
if (_root.man.direction == "left") {
_root.man.disableLeftObject = true;
//_root.bg._x -= 20;
}
if (_root.man.direction == "right") {
_root.man.disableRightObject = true;
//_root.bg._x += 20;
}
if (_root.man.direction == "up") {
_root.man.disableUpObject = true;
//_root.bg._y -= 20;
}
if (_root.man.direction == "down") {
_root.man.disableDownObject = true;
//_root.bg._y += 20;
}
} else {
_root.man.disableLeftObject = false;
_root.man.disableRightObject = false;
_root.man.disableUpObject = false;
_root.man.disableDownObject = false;
}
}

Tilebased Game: Collision Detection Problem
hi,

im making a game in isometric view, but ive got some problems with the collision detection... my char moves around but the collision detection doesnt works.. ive read some tutorials on tonypa.pri.ee about tilebased games and collision detection, but he only uses collision detection in 2d array maps and i want to use it in 3d array maps..
could someone help me plz with the collision detection because it working at all
(i know i dont use 3d arrays untill now but im still working on it )

this is my code so far(its in the attachment)

Aaargh Flash5 Car Game Collision Detection Problem.
Hi there. Im tearing my hair out! My problem is this. I have to create a car game in Flash 5 for college. My car need to drive along the streets and if it hits a wall go to a game over frame. Thats all fine but the damn collision detection is too sensitive. Im using hitTest like below
onClipEvent (enterFrame) {
if (this.hitTest(_root.route1car)) {
_root.gotoAndStop("gameOver");
}
}


The game keeps ending though when the car is nowhere near the buildings walls. The bounding boxes of the car and building are not even touching. I cant for the life of me work out where the problem is. Im using hitTest as I dont wanna programme in all the building coordinates as that'd take me forever.

I know this all sounds a mess but if someone could look at the FLA enclosed and see if you have any ideas it'd be much appreciated. Ive included only the frames that hold the main game. Any help or suggestions would be great. Thanks in advance.

Collision Detection (Won't Allow Moving Man To Walk Through Walls) - Game Help
Hi Guys, I've got a man walking on top of an image of an apartment, but at the moment he can walk anywhere (controlled by the keyboard).

I have added 2 layers. One called 'Walls', this contains transparent images mapped around the walls, each part of the wall is a movie clip called 'walls'. When the moving man hits a part of the wall, i want him to stop and not be able to go through the wall.

The second layer contains transparent movie clips on objects (i.e the one on the cooker is called 'cooker') and i then want it to go to different frames depending on what object he walks up to.

The flash file is at: http://www.dhardy.co.uk/Walking.fla (1.4MB).

Thanks in advance! Dave.

Collision Detection "game Map"
Hi there. I've got a slight problem, maybe you could help me....

scene:
- a 'person' / object
- a map

the map has wholes and edges on it AND is placed in a 45/45/45 degree angle.

Problem:
I want to do a collisioncheck between the 'person' and the map. All that to accomplish the person not walking off the map.
The HitTest option from flash does not resolve my problem because it does not look at the content of the movie but the boundingbox.

I'm sorry, my english is not that good as it should be, i'm from the netherlands....

Thanks in advance

Collision Detection "game Map"
Hi there. I've got a slight problem, maybe you could help me....

scene:
- a 'person' / object
- a map

the map has wholes and edges on it AND is placed in a 45/45/45 degree angle.

Problem:
I want to do a collisioncheck between the 'person' and the map. All that to accomplish the person not walking off the map.
The HitTest option from flash does not resolve my problem because it does not look at the content of the movie but the boundingbox.

I'm sorry, my english is not that good as it should be, i'm from the netherlands....

Thanks in advance

Collision Detection
I have many instances of a movie clip (by using duplicateMovieClip) on my stage, each with a name of "clip1", "clip2", "clip3" etc.
I have many instances of another movie clip, like the one above, but all derived from a different original movie clip. They're named "something1", "something2" etc.
I want to put an "if" statement that performs a "hitTest" between one of the "something" movie clip instances and ANY of the "clip" instances.
This is the code I have inside the onClipEvent (enterFrame) of the "something" instance:
onClipEvent (enterFrame) {
if (this, hitTest(_root.varClip)) {
this.removeMovieClip();
}
}
and I have this code in a frame on the _root level
for (var i = 1; i<=3; i++) {
_root.varClip = ["clip"+i];
}
Nothing is working this way. Is there some other way that I can check the collision using arrays?
Am I mixing up the paths?
I'd really appreciat some help with this. I feel like I'm so close already.
Thanks
Kevin

Collision Detection
Alright troops?

I wonder if any kind (and talented) souls could give me a hand? I'm trying to build a pac-man type maze game and I'm not sure about how to produce collision detection to stop my character goin' through the walls. I'm really not sure where best to begin on this one, so any advice at all is greatly appreciated.

Cheers

Collision Detection On 5
I'm using the collision detection feature on Flash 5, which works nicely, but I don't know how to make a movie detect another instance of itself without detecting itself

To illustrate what I mean, I'm making a battle of Ants. Each ant is created by an Array, and I want their heads to detect the collision with another. So I'm using the following code within the 'head' movie:

flag = this.hitTest(_root.ant);
if (flag == true) { do something... }

What should I use instead of _root.ant?

Thanks!

Collision Detection
Hi,

I am trying to make a game. I have a character and a 3d floorplan he walks around in. Instead of moving the guy, I move the floor so it looks like he is moving, but he stays in the center of the screen. So I got the hit test to work, but I have one big object that my character is colliding with (the map). I know that I can break apart the floor and have separate walls, but I was hoping there is a way to keep using only one object. The object is vector, so why can't flash only see the filled in areas? If anyone can help me with this, I would greatly appreciate it. Thanks.

Stan

Collision Detection
hey guys
i'm trying to create a game where you're a tank and you move around using the mouse (you click where you want to move to and the tank drives in a straight direction towards the mouse)

I know how to make the tank move, the thing i need help on is the collision detection, the tank is a rectangle movie clip and the object i am colliding with is a rectangle too.

this is what i need to happen:
when the tank collides with the object, the tank will stop
there's a varable in the tank MC that if it is set to TRUE the tank will move, if FALSE the tank will stop where it is
the variablie is called 'GO'

i know the basic

if(this.hitTest(_root.object)){
this.go = false;
}

but if i do this, then the tank will still be touching the object, so when the tank touches the object, i would like the tank to be moved 5 pixels away from it so it wouldn't be touching the object

is there anyway i can do this?

Collision Detection
Ok, um i have this video clip that i can move around the screen using the arrow keys on the keyboard. I also have some other graphics on the stage. Now, what i want to do is when the movie clip touches one of these other graphics the movie clip stops and it cant go over the particualr graphic. so i now hae to move the mvie clip around the graphic. Can someone please help me on how to do this. Your help is greatly appreciated. Thank you in adavance for any help you can offer.
Kind Regards,
The Prophecy.

Collision Detection
i want to have a mc follow the cursor and when it collides with another mc an action is done.

Collision Detection
Here's what I'm trying to do:

Go to and play frame 5 when MC1 AND MC2 have both been dragged into a certain area.

I got both MC's to be draggable into a red box but how do I check to see if both are there and if so move on and if not wait until they are?

Thanks

Collision Detection
hello,

i have a MC which carries the follwoing script. when the MC detects collision, corresponding MC instance will start.


onClipEvent (enterFrame) {
this._y+=laserSpeed;
if (this._y<-50) {
this.removeMovieClip();
}
if (this.hitTest(_root.map.ground.target_pro)) {
_root.pro.gotoandstop(2);
this.removeMovieClip();
}
if (this.hitTest(_root.map.ground.target_edu)) {
_root.edu.gotoandstop(2);
this.removeMovieClip();
}
if (this.hitTest(_root.map.ground.target_work)) {
_root.work.gotoandstop(2);
this.removeMovieClip();
}
if (this.hitTest(_root.map.ground.target_ex)) {
_root.ex.gotoandstop(2);
this.removeMovieClip();
}
if (this.hitTest(_root.map.ground.target_ski)) {
_root.ski.gotoandstop(2);
this.removeMovieClip();
}
}

Q1 does anyone know why only four out of five collision detection work? the MC "pro" does not detect collision...i ckecked instance names etc but just don't have a clue why it doesn't work!!

Q2 does anyone know how to create a master script so that i don't have to repeat the same if(this.hitTest...) script? how can "this" (the main MC that holds the script above) find out collided object's instance name??

any help greatly appreciated!
Thanks!

reynard

Collision Detection
does anyone know the ode for collision detection and how to make a rotating objet move in the direction it's pointing?

example :

I I
I I I = wall
I I <O> = object
I I
IIIIIIIIIIII IIIIIIIIIIIII

<O>

IIIIIIIIIIII IIIIIIIIIIIII
I I
I I
I I
I I

i want the user to be able to press UP to go forwards and DOWN to go backwards. He can the press RIGHT / LEFT to choose the direction he will move in...

plz help

Collision Detection
Ok, I'm making a pong game, but the collision detection system I'm using doesn't work too well. The ball will be inside the paddle before it reverses direction and sometimes it just goes straight through. I know there's a better way than just using hitTest(even with the borders on). Anyone have ideas?

Collision Detection Help
Hey--



I'm having a problem with my collision detection. I followed a tutorial and downloaded the fla to double check, but its not working. I have one mc called laser, which's actionscript is "


onClipEvent (load) {

laserMoveSpeed=20;
this._x=_root.spaceship._x+90;
this._y=_root.spaceship._y;

}

onClipEvent (enterFrame) {
if (this._name<>"laser"){
this._x+=laserMoveSpeed;
if (this._x>600){
this.removeMovieClip();
}

for (i=1; i<=_root.numEnemy; i++){
if (this.hitTest( _root["enemy"+i])){
_root.score+=100;
_root["enemy"+i].gotoAndPlay( 2 );
}

}
}
}
"


And the enemy it's killing's movie clip is called enemy one, and its action script is"

onClipEvent (load) {

function reset(){
this._x=600;
this._y=random(200)+100;
enemySpeed=random(4)+1;
this.gotoAndStop(1);
}

reset();

}

onClipEvent (enterFrame) {

if (_root.spaceship.scrollStart){
this._x-=enemySpeed+_root.mainGround.groundSpeed;
} else {
this._x-=enemySpeed;
}


if (this._x<-10) {
reset();
}


if (this.hitTest( _root.spaceship ) ){
_root.gotoAndStop ( "gameOver" );

}


}

"



any help appriciated.


Thanks

Collision And Detection
Can anyone help me?.. I need to know how to simulate molecules leaving a surface within a chamber. The simulation
should behave as real as possible wherein if a molecule hit
the wall of the chamber, it should deflect at the same amgle

Collision Detection
hi all

1. i have drawed some lines with actionscript

2. i have let's say a circle which i move around

now i need to make a collision detection so when the circle does collide with one of the lines it has to stop.

can someone tell me how i can do that.

thx a lot in advance

marcel

Collision Detection
am trying to create game where someone throws ball to hit target. the target is moving. the ball is necessarily embedded in another movie clip. how do i get the x y coordinates to consider the same registration basis. meaning, x for one is not x for the other so i cant have "if ball.x = target.x then"

Collision Detection
Hi,

Is it possible to do pixel perfect collision detection with a clip on a clip in Flash 5? I know its possible using the mouse x,y but need to know if theres a way of doing it between 2 clips.

thanks

phil.

Collision Detection
Could someone please take a quick look at this Fla I have 2 mcs that u control via the keyboard one is with the arrow keys and the other is with W A S D keys.
I have another two movieclips that are a sort of barrier to the others when the green square hits the big blue square u r stuck the same with the other one but this is not the problem.

The problem is that the two keyboard controlled movie clips overlap. Is there a way to when they collide they hold there position on the stage but u are still able to maneuver them just not in the direction of the other MC.

Thanks

Collision Detection.. Help
Hi ya

Im making a fighting game and Im stuck on the actionscripting...
I have a 'health bar' for each player and when player 1 hits player 2 I want player 1s health bar to go up a notch, etc. Ive created the movie clips for each health bar but dont know what action scripting to put in to make it all come together....
Its driving me mad!!!

(Theres only 3 moves for each player and they're all seperate movie clips, incase you were wondering)

Please somebody help!
thankyou
lou

Collision Detection
What is the best way to detect collisions between multiple objects of certain types, for example, any of a "laser beam" movie clip hitting any "bad guy" movie clip on the stage at any time, like in a spaced invaders game? I tried looping through all the laser mc's on the stage and seeing if they hit any of the bad guy clips, but i think it is bogging down the proc so much that it misses most of the hits...

Dave

Collision Detection
What is the best way to do collision detection for a flash game with a bunch of different "bad guy" objects, and "laser gun" objects, or something like that?

Dave

Collision Detection?
Hi!

I'm making this webpage where you drive a car around with the keyboard. When the car drives over certain objects, I want them to light up, and if you press e.g. enter when over one of them, a movie should open.

I have read all kinds of different tutorials about collision detection to try to pick something up there, but I just can't make it work...

Would really appreciate it if someone would be willing to help me out on this one!!

Tnx, Thomas.

Mc Collision Detection
I've followed the basic tutorial on mc collision detection and attempted to ammend it slightly for my needs.... it didn't work.
I've attached the fla file as it's the best way to show what I'm attempting to do:
basically, I need a gotoAndPlay action to occur when 2 mc's collide - the two clips are currenty one stationary and one a drag mc. when one is dragged over the other I need the 3rd mc 'jwooClip' to go to and play frame 2.
I've used the correct actionscript for this part but not sure if it's tied in correctly with the rest of the script????
I know this makes little sense but it will all be clear if you view the fla file.
Any help will be appreciated, even if it's a link to another tutorial (intermediate maybe??)

Collision Detection
Is it possible to use collision detection to make objects bounce off one another?

Help Please (Collision Detection)
I'm working on a very basic RPG engine, and I'm trying to work on collision detection (if you run into an enemy on the map, you go to a battle screen).

I've tried several collision detection methods from several tutorials, but I can't get it to work. I want to play Frame 2 when the black circle (character) hits the red square (hitbox). If someone could try some code in there, and find something that works, I would be very grateful. The file is attached.

Collision Detection
i have looked at flashkit, macromedia help, and some more things, each one gives me a code, alwase the same, but when i put it in my movie it dosent work, my two coliding movie clips are "a" and "b" this is my code
if (a.hitTest(b))
action
1. what is wrong with that?
2. maby im putting the code in the wrong place, so where should i put it?

I Think This Has To Do With Collision Detection
I'm not sure but how would I go about making it possible to make a character your moving with the keyboard walk into a door to a house and upon the character touching the door the screen would change to the interior of the house? If there is a tutorial on this subject point me in that direction, but I wouldn't know what to search for to find this.

Collision Detection
Hi. I'm actually developing an adventure game in flash. The character movement has been programmed. For the collision detection, I would like to ask something. Should I include the collision detection code inside together with the character movement code or include into the map or into another separate frame? By the way, I really need your help. The map I have designed is actually divided into 6 parts namely top left, top middle, top right, bottom left, bottom middle and bottom right. Each part has the size of 550 X 400 pixel. Do u guys have any code for the collision detection for the map? I'm really confused and badly need your help. If there is any, I would be really grateful to you. By the way, could you guys kindly include some comments in it so that I could understand the coding purpose? Thanks alot....

Help With A Certain Collision Detection...
I have this new file i am working on, I shouldnt put it in games because I think it can be solved very easily, it's just help with making the ball not sink into the platform. You can see it easier with this file attached.

The ball sinks into the platform in which it is supposed to bounce on.

Collision Detection Help
i need some help with my collision detection. i thought that i had the code all right but i dont. here is my code:

if (_root.lemon, hitTest(_root.player)) {
gotoAndPlay("gameover")


lemon = my enemy that the code is on
player = me...
"gameover" = the frame that it goes to and plays...

Collision Detection
Hi there!!

I would like to find out how to test a collision detection of two or more circles.

If anyone knows how to do it, please give me a hint.

Collision Detection Help
I'm more than a little stuck as to how to sort out this problem with collision detection I have for a game I intend to make / remake, using flash to sort out the logic problems involved with such matters as collision.

My problem is determining what course of action to take when bouncing off a wall. (see attachment for details)

The simple types are vertical and horizontal walls but sorting out corners appears to be a tricky one, what with there being so many types of them!!

Using Flash MX and actionscript 1.0... or is it 1.1, well it's not 2.0

Collision Detection Help
I made a simple scene where there is a space ship and meteors flying towards the spaceship. The objective is that we drag the space ship out of the way of the meteors and if we don't it would detect the collision and go to the next frame. I made a normal movie clip as my spaceship and the meteor is also s movie clip but inside of the mc it has the animation of the meteors flying by!

All i done so far was the start drag:

on (press) {
this.startDrag()




tried this but it didn't work:

if (this.hitTest(_root.meteor_mc, _root.meteor_mc, true))
trace("hitTest true");


PLEASE CAN SOMEBODY HELP ME! I would like to put the fla file but i don't know how.

Collision Detection.
does any one know how to do it so that when the square is over the circle although it is set to true i would like an action to happen such as jumping to the next scene? I have put my file attached below, if anyone has any ideas. Thank you.

Collision Detection
hi
I have 2 objects and i am duplicating thosse two object and moving then in their oposite direction so they will collide to each other. my problem is that i am not been able to dectect which object colided with which one.

Thanx in aqvance for any sort of help provided to me

[F8] Car Collision Detection
right now the collision detection sucks it just bounces back and it is glitchy.
it just checks 4 points to see if the car has hit a wall. Is there a tutorial on how to make better collision detection?

Collision Detection On
on circles and triangles, is this possible?

Help With Collision Detection
hi guys

I want to create a collision detention system where objects move away from each other if they get too close, much like in the link below (done in java I think):

http://www.aharef.info/static/htmlgr...joeprice.co.uk

Could anyone point me in the direction of a potential tutorial for achieving collision detection along these lines?

Many many thanks for your responses

Joe

Copyright © 2005-08 www.BigResource.com, All rights reserved