ActionScript 3.0 :: Flash MovieClip - HitTestObject For The Collision Detection

Apr 28, 2011

I have a bullet object and a boulder object (both movieclips originating from JPEGs) in my AS3 game. The trouble I'm having is with hitTestObject for the collision detection, as it's taking in to account the transparent areas and basing the collision on the bounding boxes surrounding the movieclips. This is a problem because the collisions are not accurate and if the bullet (long and thing line shaped) is at an angle...the bounding box is quite large around it...and it's "colliding" with the boulder even though it's visibly many pixels away. Is there a way to detect MovieClip collisions that ignore transparent areas?

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Collision Detection - Use HitTestObject?

Oct 28, 2010

HitTestObject seems to check collision of bounddaries of shapes, it seems to consider everything rectangular. Also if one object jumps two pixel and other five pixels on EnterFrame it seems like there won't be any hit detection. Seriously guys what else method do you use, if you use hitTestObject how do you use?

View 1 Replies

ActionScript 3.0 :: Collision Detection HitTestObject()?

Apr 26, 2011

Here is part of my code:

Code:
protected function button_clickHandler(event:MouseEvent):void
{

[code].....

View 0 Replies

ActionScript 3.0 :: Collision Detection - HitTestObject Broken?

Feb 18, 2008

I'm making a basic platformer to familiarize myself with AS3. I'm currently having an issue with the HitTestObject and HitTestPoint methods. Currently my game consists of a character who can run and jump, and a box which should prevent him from falling. I have two questions (the complete code is attached and is only
briefly referenced in the questions):

1) Why is my HitTestObject broken? The issue I'm having is that when I perform box.HitTestObject(character), the screen shakes in most of the character poses (i.e. facing left or right) but not when the character is crouching. I suspect this is because the bounding box in the different frames of my character movieclip are not the same. Is this the case, and how can I make certain my bounding boxes are exactly the same across all frames?

[Code]....

View 1 Replies

ActionScript 3.0 :: Use Collision Detection (hitTestObject) With IK Armature?

Dec 29, 2010

What I am trying to do here is to simply import an armature, then I want to add an object to the stage which, when collide with the armature, will do something (dissapear etc). is that possible to do with the armature?

View 1 Replies

ActionScript 3.0 :: Collision Detection Is Not Working - HitTestObject Function

May 17, 2010

Collision detection is not working for me. My objects are planes in 3D space.

1) I have tried hitTestObject function.

2) I have also read [URL] and tried it. With no success in both cases.

View 6 Replies

Flash :: Collision Detection Between A MovieClip On The Timeline And One Drawn?

Jan 19, 2012

I'm making a program that lets the user draw shapes on the screen with the mouse. When they're done they press a button to finish. The user is only allowed to draw on a certain area of the stage, to control this on the timeline i have a movie clip that takes up all the space the user isnt alowed to draw in.When the user presses the button i want the programe to check that the shape the user drew isnt touching the moiveclip. I want it to do this without taking the border of the movieclip into account so i cant use hitTestObject()

heres what i have so far:
//------------------------------DRAW SHAPE------------------------------
private var shape:MovieClip = new MovieClip();

[code]....

View 2 Replies

ActionScript 2.0 :: Collision Detection Within Rotating MovieClip

Feb 15, 2007

I am working on a snowboarding game, And have two points of collision detection on the board:
x-----xOne at the Front of the riders boardOne at the Back of the riders boardThese two points of collision are placed within the rider.movieClip, and not on the _root timeline, as the rider movieclip can rotate etc as it rides through different gradients of slopes. I have used a largely basic method to obtain the X,Y positions of each collision point, using the following method:

Code:
var backX:Number = _root.rider._x+_root.rider.backDetection._x;
var backY:Number = _root.rider._y+_root.rider.backDetection._y;
(The same for the frontX and frontY) As you can see, it simply adds the offset of the detection points positions from the riders x, y therefore when the rider movieclip is rotated during gameplay, the rotation is not accounted for and it still searches for collision in exactly the same positions.

I am using this for collision checking:
Code:
this.hitTest(backX, backY, true)
Which is placed on the ground movieclip (what the snowboarder is riding on). Any better way of doing such collision checking, or how to account for rotation? is localToGlobal() the answer?

View 1 Replies

Flash :: AS3 - HitTestObject Collision Not Registering Correctly

Aug 7, 2011

I had a problem with my hitTestObject collision detection a couple of days ago which has since been fixed (How can I solve my hitTestObject Collision Null Object Ref Error) with the help of you folks. My problem now is as such: When my "enemy.hit" comes into contact with "player.hit" it registers as a hit - this is good. When my "building.collide" comes into contact with "player.hit" it registers as a hit - this is good.

However, when my "building.collide" comes into contact with my "enemy.hit" it does not register, but sometimes it does register even though the only enemy on-screen is many pixels away from it - as if either the building or enemy "hitBox" is somewhere other than directly on the graphic(MovieClip in this case).

[Code]....

View 3 Replies

Collision Detection Incorrectly Detecting Collision?

Oct 16, 2009

In my file (AS2), I have a small square at the middle of the page. Diagonally to the right, I have a vertical wall which is a rectangle. Pasted inside my small square, I have the code:

onClipEvent(enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (this.hitTest(Wall._x, Wall._y, false))  _x =

[code]......

View 1 Replies

Actionscript 3 :: Pixel Collision Detection For Flash

Jan 11, 2010

I was told the pixel detection is costly for regular windows games. Is this the same for flash ?? Or would pixel detection be lighter compared to other detections flash has to offer. Flash has the getPixel32 method which makes it easy for detecting pixels. If I am bliting my game, would it be wise to use getPixel32 for collision detection. Or should I just check for specific tiles?? Is getPixel32 limited to the display object it is in ?? In other words, can I detect any pixel regardless of what layer it is on in the display list.I probably can figure this out on my own but I want to ask first to save me some time. But does anyone have any code or good sources on how to go about doing this if it is reasonable.

View 6 Replies

AS3 :: Flash - Continuous Movieclips With Collision-detection?

Mar 8, 2011

I'm starting to understand ActionScript and getting better with it. However, I'm building a platform game with an unlimited length. What would be the best way to create the "block" the player is jumping on?

Of course collision detection for these movieclips is needed (nicest would be to do it without a giant loop through an array, etc. on every frame). There's probably something like 5 block on the screen at the same time.

View 2 Replies

Flash :: For Each Loop And Collision Detection In Actionscript 3

Jun 11, 2011

I am in the progress of making a Flash game and currently I am doing the coding for collision detection. The collision detection will be for detecting if the player is running into obstacles, and if the player runs into the obstacle, then it will stop him from running through it. Here is my code that I am using for collision detection:

[Code]...

View 1 Replies

Actionscript 3 :: Flash - Optimizing Collision Detection

Oct 25, 2011

I'm trying to make my first game in Actionscript 3. Its a simple artillery game where you have a gun at bottom left corner and AIs flying across the screen which you have to shoot down. Now, in a classing shooter game how this is achieved is either by firing a bullet from the gun and doing a hitTest of that bullet with the AI movieClip or by simply removing(or playing the death animation) the AI movieclip. But here's the problem. I dont wanna do either of them. I want to show a gun with a rapid fire rate and hence no bullets. And I also don't want the player to click exactly ON the AI movieclip to destroy them (just the gun/turret pointing at the correct direction should be enough). So here's what I tried. This image should help picture the whole thing.

Tried attaching a 'line' to the turret and checking for collision with AI clip. This obviously failed because of the bounding box problem when the line is slanting.
I tried putting multiple tiny movieClips ON the line and iterate through them in a loop and checking for any collision with the AI. This method partially worked, but it was too slow and didn't seem like the 'correct' method. I draw 2 hypothetical lines. One between p1 and p2 and other connecting p3 and p4 (please see the image above). p3----p4's lenght = AI.width and is a horizontal line running right through the center of the AI MovieClip. Upon mouseClick I check for any intersection between these two lines. Now if I have multiple AIs on the screen, Again i need to iterate through each of them, draw a fresh p3-----p4 and check for intersection with p1-----p2.

[Code]....

View 1 Replies

Flex - Collision Detection Flash Builder?

Nov 23, 2011

I am having trouble with getting some code dealing with collision detection to work. I have tested to ensure that it does detect the collisions, and it does, however I am unable to get it to work as it just walks through the block. I also tried just taking away -10 from the x value after it collides but it will stay for the first couple of tries then just walk through the block.

private function collisionDetect(evt:Event):void{
if(IMG3.hitTestObject(block)){
if(IMG3.x > block.x){
IMG3.x = block.x-1;
}
}
}

View 1 Replies

ActionScript 2.0 :: Collision Detection For Flash Game

Jun 7, 2011

I have a movieclip called nest, which also contains a movieclip called wall. The bullet is created in the nest movieclip, and I am trying to make the bullet disappear when it hits the wall.The problem is, when the bullet is at B, the hittest succeeds when there is nothing at b. [code]The bullet just passes through the walls.

View 2 Replies

ActionScript 2.0 :: Multiple Wall Collision Detection In Flash CS3

Feb 26, 2010

I'm using Flashcs3 in AS2.[code]My character gets stuck in walls and slows down trying to get out, also, hes about 10x faster now. any suggestions? Im working on a flash overhead shooter, multiplayer only. and I need the script to work so there can still be a bullet collision on each wall and not to be able to walk through it.

View 6 Replies

Flash :: Collision Detection In A Tile Based Enviroment?

Feb 11, 2010

I am having problems with my collision detection. basically when I hit a solid tile my character's body is half way in the tile already. here is my code.The properties wY and wX are my game world positioning. Not the stage positioning. dx and dy is the velocity the character is traveling. This first snippet of code is within a game loop. The focus point of my character is centered on the x axis

package com.objects
{
import flash.display.MovieClip;

[code].....

View 4 Replies

Flash :: Collision Detection. Rotating And Hiting At The Same Time?

Feb 23, 2010

What I want to do is rotate the object and have its collision box rotate with it. I want the rectangle to rotate so it looks like a diamond and have one of its sides hit the object in a per pixel fashion. From my reading of some books and websites it seems that normal rectangular collision and hitTestObject collision won't do for this problem. I have searched high and low and want to know if anyone has a solution to hit detection with moving and rotating objects. Here is my current collision code with rectangles

colboxrect = colbox1.getRect(this);
robotrect = robot1.getRect(this);
if(robotrect.intersects(colboxrect))

[Code]...

View 1 Replies

Actionscript 3.0 :: Flash - Sphere To Rectangle Collision Detection?

Apr 19, 2010

for the past two weeks I've been working on coming up with a collision detection system for my game in flash CS4. No matter what I try for some reason I just can't seem to do it, and I don't know how to fix it. This has never been an issue for me, I would even settle for basic rectangle to rectangle collision if I could, but no matter what I do I end up screwing it at all up. Somehow the collision detection either doesn't work at all, works for one side and jumps the guy through the wall on any other side or I think at one point it worked for two sides as long as I didn't hold down more than one movement key.

I've constantly scrapped what I've done over and over, right now I have no source code to present. I'm totally lost and confused, and my deadline for getting this done is today in a few hours. I really wanted to figure this out on my own but honestly I just don't see what I can do, I've got sphere to sphere collision detection working perfectly for my player and other spheres, but the walls are squares lined up to form long rectangles, and I just can't seem to get it to work. I'm dynamically loading the square-wall blocks as tiles to form a dynamically loaded map, and then I'm iterating through each individual block to determine if collision has occurred with the player. I think somehow I'm not managing the results right, or maybe I somehow need to be able to determine which direction the player hit the wall from, but I just don't know how to do it.

I've been staring at the screen for the past 3 hours trying to work something out but nothing is coming to me, example from a flash-type game or something similar I would be very grateful! (I've done this countless times in C++, C#, and java. I don't get what is going on in flash :-(((( )

View 2 Replies

Flash :: Collision And Bounce Detection From Array Of Points

Sep 18, 2011

I have an array of points that I will use to generate a closed polygonal fence on the outside of a game stage (2D). I wish to have collision detection between this fence and a bouncing ball-like object on the inside. Additionally, I would like to be able to arbitrarily add/remove/redraw the fence in realtime and have the collision detection still operate realistically. I have considered drawing a Sprite/Shape from the points and doing a HitTest at each frame to check whether to bounce or not. My question: is this the best/correct way to accomplish this goal? Consider something like JezzBall with diagonal lines of any angle a simulation of what I'm trying to do.

View 2 Replies

ActionScript 3.0 :: Flash Very Basic TileBased Collision Detection

Sep 4, 2010

So I've never dealt with collision detection since I mostly have just made simple web-designs, apps, and things that just don't make use of physics or anything like that. But today I decided to fiddle with it a little and was pretty excited when I started out just using a square to move around with keys and so I made some walls to figure out some collision stuff.

And basically, I can't move out of the wall once I collide. I know I could make it so when I collide the sprite backs off a few pixels, but it causes that jittery effect. So I was wondering is it possible to check for a collision before the block is animated?

[Code]...

View 1 Replies

ActionScript 3.0 :: Flash : Collision Detection Between Character And Platform?

Aug 10, 2011

whenever I start my game my character just falls through the platform. No Compiler errors are appearing, and there's nothing in the outbox. I'm pretty sure it has something to do with my character not knowing that it must land on the platforms, but how would I write that?

View 2 Replies

Arrays :: Flash - Collision Detection Between An Instance In Motion And Array Does Not Work?

Mar 8, 2012

I am trying to test the collisions between a bullet and an array of enemies in Actionscript 2. However it is not sensing a collision.This is the code in the bullet.

onClipEvent(load)
{
facing = _root.player.facing;
speed = 1;

[code]....

View 1 Replies

ActionScript 3.0 :: HitTestObject Collision Coordinates?

Aug 28, 2011

my scene a group of cups moving randomly on the stage, with a hitTestObject the cups change their direction when one cup crash with another one, then i need to get the collision point coordinates to add some effect, o you know how can i get that point?

View 4 Replies

Actionscript 3 :: Flex Collision Testing With HitTestObject

Aug 14, 2009

I'm trying to test clipping on two canvases. Both canvases are 100px wide. They're 20px apart. I've placed a label inside one and made it 200px wide. Scroll bars will show up on the canvas. When I don't have the label inside and use hitTestObject it returns false. When I place the label inside it returns true. Is there any way to alter the canvas with the label inside so that it doesn't expand to the width of the label?

[Code]...

View 1 Replies

AS 2 :: CS3 Collision Detection Ie Hit Test

Jun 21, 2010

Im currently working on a demo flash game built on AS 2.0. im a very beginner to this flash and AS and im stuck up with a very silly concept though im not able to overcome it. the problem i have is with collision detection ie hit test and im really struggling with it.

[Code]....

View 1 Replies

Actionscript 3.0 :: Collision Detection Kit?

Oct 16, 2010

Im using CDK, and I want to exclude color black.im using this: __collisionList.excludeColor(0x00000000);

View 5 Replies

IDE :: Easy Way To Do Collision Detection?

May 3, 2009

Its been many years since I've used flash and I was just wondering what the easiest way to do collision detection was now. I know that there was some hit test bounding box stuff present earlier but I don't know the capabilities of flash cs4 and the advances that have been made. Google searches have yielded things like complex pixel-perfect collision detection but not a lot seems to have been written about CS4 yet.

View 3 Replies

ActionScript 3.0 :: Get Some Collision Detection Working

Mar 19, 2009

I am trying to get some collision detection working. What I have is a ball moving around the stage. There is a box in the middle which when the ball hits, I would like it to bounce off the box. I can get the x axis working fine using hitTestObject but when I detect for collisions on the y axis, the two axis conflict. Does anyone have a way of doing this properly?[code]

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved