Skip to main content
Known Participant
March 1, 2008
Question

movie on movie hittests

  • March 1, 2008
  • 2 replies
  • 398 views
Hello,

I've always had this problem but never really been able to solve it.

When you have a ball, ground, and an acceleration variable.

If the ball isnt touching the ground it accelerates until it does, but ive never been able to get the bottom of the ball to line up with the ground properly. The registration point of the ball is at the bottom of the object itself. Any solutions? I've attached a simple example without any of my attempts to fix my issue.
This topic has been closed for replies.

2 replies

Known Participant
March 2, 2008
Hmm, It didn't seem to fix the problem. That If() statement you added:

if((_root.ground._y - _root.ball._y) < accel) {} doesn't equal true when you trace it. Also, that code wont work if the ground isn't flat, which it isn't for what I need.

Thanks
kglad
Community Expert
Community Expert
March 2, 2008
:

Known Participant
March 3, 2008
umm that still won't work, the ground isn't flat, so the Y value of the ground hitting the ball is always changing. making the balls Y = the ground Y will just place the ball in the middle of the ground or wherever ur registration point is.
March 1, 2008
You should limit your last acceleration to be no more than the difference between ground Y and ball Y if you want it to only touch. (BTW you don't absolutely need hitTest to do that). rather than forcing an acceleration increment, can you calculate what it should be to get them to touch? What I posted will almost always slow the ball down on its final pass through the onEnterFrame. And if you are going to do nothing more with the ball after it hits the ground, you should delete the onEnterFrame function within the if statement once contact is made.