Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-26-2011, 03:00 AM   #1
NANNERS
Registered User
 
Join Date: Aug 2010
Posts: 16
Default [AS2] Collision with the wrong object

I have my player named "Player" and a little square named "Feet" at its feet. They are both Movie Clips.
I have a simple box named "Crate" and a simple floor named "Ground".
Way back when I used to have it do collision with the Player itself, which worked fine. Then I swapped out the line that said "Player" in the collision check with "Feet", but it continues to use "Player".

ActionScript Code:
TouchingGround = false; // Used by my gravity code, if false, player will fall     for(i in _root)     {         if(typeof(_root[i])=="movieclip") // Yes they're all movie clips         {             if (_root[i].ofType == "GROUND") // Each object I want collision with has this variable applied to it             {                 if (_root[i]._name <> "Player") // Because the feet are always touching the player                 {                     if (_root.Feet, hitTest(_root[i]))  // If the feet are colliding with any one of these objects                     {                         TouchingGround = true; // Disable falling with my gravity function                     }                 }             }         }     }

I've quadruple checked names and made absolutely sure everything has the right variable. In fact I can place whatever I want where "_root.Feet" is (like "hfksalhfklsa") and the code compiles just fine and continues to use the player as colliding check. If I delete the TouchingGround = true; then I will fall forever, so it is actually accepting the code.
Does anyone have any idea what's going on? I can't see any reason it won't use my Feet movie clip. It only ever uses the Player movie clip for collision.
NANNERS is offline   Reply With Quote
Old 01-26-2011, 03:08 AM   #2
NANNERS
Registered User
 
Join Date: Aug 2010
Posts: 16
Default

I really hate it when I do this.
It happens every time. I post a question and then I figure it out a minute later, even though I'd been spending the past couple of hours trying to figure it out. Now my question is "why is it this way?"
I took that code that was on the Player movie clip and placed it on the Feet movie clip, and suddenly it worked. it's as if it didn't matter what I wrote as the first part, it just did collision with the object it's placed on. There I go again. I guess I figured it out just asking. Well if anyone has the same problem, there's your answer.
NANNERS is offline   Reply With Quote
Old 01-26-2011, 01:16 PM   #3
rrh
throw a trace() in there
 
Join Date: Dec 2006
Posts: 1,982
Default

Code:
if (_root.Feet, hitTest(_root[i]))
Is that supposed to be a comma, or a period. ?
rrh is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:22 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.