Be a Supporter!

Collision Dectection Help

  • 554 Views
  • 13 Replies
New Topic Respond to this Topic
MiniNova
MiniNova
  • Member since: Jan. 1, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Collision Dectection Help Oct. 14th, 2007 @ 12:15 PM Reply

Need some more help...

Does anyone know some actionscript that will detect when my moving object hits it then change the frame?

Cheers,
MiniNova.

3ruce
3ruce
  • Member since: Jul. 23, 2005
  • Offline.
Forum Stats
Member
Level 09
Artist
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:18 PM Reply

Look up hitTest on AS MAIN.


Murad136, heres your fucking credit ;3

BBS Signature
MrCrinkle
MrCrinkle
  • Member since: Jan. 26, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:20 PM Reply

Hits what?

im assuming you just want a simple hit detection so here it is:

if (this.hitTest(_root.movingobject)){
_root.movingobject.gotoAndStop(2);
}

Put that in whatever you want to hit with the moving object.


If you are reading this then you must be really bored.

BBS Signature
Will
Will
  • Member since: Mar. 18, 2006
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:21 PM Reply

AS : Main

AS : Main - HitTests


BBS Signature
dJtl
dJtl
  • Member since: Oct. 12, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:25 PM Reply

hitTest flash wiki it.


BBS Signature
MiniNova
MiniNova
  • Member since: Jan. 1, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:25 PM Reply

At 10/14/07 12:20 PM, MrCrinkle wrote: Hits what?

im assuming you just want a simple hit detection so here it is:

if (this.hitTest(_root.movingobject)){
_root.movingobject.gotoAndStop(2);
}

Put that in whatever you want to hit with the moving object.

thanks but it came up with:
________________________________________
________________________________________
__________
**Error** Scene=Scene 1, layer=Walls, frame=1:Line 1: Statement must appear within on/onClipEvent handler
if (this.hitTest(_root.movingobject)){

Total ActionScript Errors: 1 Reported Errors: 1
________________________________________
________________________________________
__________

I want is if my object (that moves with the arrow keys) hits a wall (the wall is a movie clip) the whole movie will change to a different keyframe.

7IsUnlucky
7IsUnlucky
  • Member since: Jun. 12, 2007
  • Offline.
Forum Stats
Member
Level 26
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:27 PM Reply

At 10/14/07 12:25 PM, MiniNova wrote: stuff

onClipEvent(enterFrame){
if(this.hitTest(_root.wall){
_root.gotoAndPlay(frame);
}
}

Try that

MiniNova
MiniNova
  • Member since: Jan. 1, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:36 PM Reply

At 10/14/07 12:27 PM, 7IsUnlucky wrote:
At 10/14/07 12:25 PM, MiniNova wrote: stuff
onClipEvent(enterFrame){
if(this.hitTest(_root.wall){
_root.gotoAndPlay(frame);
}
}

Try that

it looks like it'll work... do i have to do the instance name of teh wall where it sez. So it'll look like this:
(_root."instance name")

I tried it normal but it said there was errors.

7IsUnlucky
7IsUnlucky
  • Member since: Jun. 12, 2007
  • Offline.
Forum Stats
Member
Level 26
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:43 PM Reply

At 10/14/07 12:36 PM, MiniNova wrote: it looks like it'll work... do i have to do the instance name of teh wall where it sez. So it'll look like this:
(_root."instance name")

I tried it normal but it said there was errors.

*sigh*

What's the instance name of your wall?

MiniNova
MiniNova
  • Member since: Jan. 1, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:46 PM Reply

At 10/14/07 12:43 PM, 7IsUnlucky wrote:
At 10/14/07 12:36 PM, MiniNova wrote: it looks like it'll work... do i have to do the instance name of teh wall where it sez. So it'll look like this:
(_root."instance name")

I tried it normal but it said there was errors.
*sigh*

What's the instance name of your wall?

I dont have oneee yet, sorry i'm really crap aint i. Still thx for da help.
Umm gimme the actionscript and tell me the new instance name of the wall.

7IsUnlucky
7IsUnlucky
  • Member since: Jun. 12, 2007
  • Offline.
Forum Stats
Member
Level 26
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 12:49 PM Reply

At 10/14/07 12:46 PM, MiniNova wrote: I dont have oneee yet, sorry i'm really crap aint i. Still thx for da help.
Umm gimme the actionscript and tell me the new instance name of the wall.

WALL

MiniNova
MiniNova
  • Member since: Jan. 1, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 01:02 PM Reply

onClipEvent(enterFrame){
if(this.hitTest(_root.wall){
_root.gotoAndStop(2);
}
}

is that right....? it dont work :'(

Will
Will
  • Member since: Mar. 18, 2006
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 01:06 PM Reply

At 10/14/07 01:02 PM, MiniNova wrote: onClipEvent(enterFrame){
if(this.hitTest(_root.wall)){
_root.gotoAndStop(2);
}
}

That should work. (i put an extra bracket in)


BBS Signature
MiniNova
MiniNova
  • Member since: Jan. 1, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Collision Dectection Help Oct. 14th, 2007 @ 01:19 PM Reply

okay thx for all ur help ur names will b in the credits...