|
-
M.D.
more angle problems
ok this one seems to be a tough one. Well for me anyway 
is it possible to use angles to determine whether an object has passed another object. Have a look at this

you see that this cannot work, also checking the axis seperatly wont work either. Because the same problem can occur, also note that gravity can effect the object, so the object can be released parallel to the center and might fall below the center before it visually passes the center
any help?
Last edited by mr_malee; 12-14-2006 at 08:26 PM.
-
M.D.
ok well this works, but the object must not be affected by gravity until it has passed, meaning its trajectory stays the same
//rd = distance vector - floored
//rel = inital vector - floored
var passX = rd.x >= 0 && rel.x <= 0 || rd.x <= 0 && rel.x >= 0 || rd.x == rel.x;
var passY = rd.y >= 0 && rel.y <= 0 || rd.y <= 0 && rel.y >= 0 || rd.y == rel.y;
if(passY && passX) //reset gravity
-
ism
if you use localtoglobal to get the red balls position relative to the white ball then the red ball has passed through the white ball (or it's axis) when the sign of the X or Y has changed.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Senior Member
Just thinking out loud here, but maybe you could "rotate" the x axis, so that the ball is at 0,0 and the moving ball is along it, if it goes to negative it crossed.
(The x-axis would be along the actual line drawn between, not the direction of movement)
-
M.D.
i might try that out blink, UnkownGuy care to elaborate, i kinda got lost
-
self-portrait
Hm, can't you use the dot product of the velocity vector and the distance vector between the two object ( from the red ball towards the center ). If it's negative
it will have passed it.
Hope I didn't misunderstand the question?
-
Senior Member
I don't mean to be the simpleton but it seems like this problem can be resolved with a hitTest. I don't see any reason you can't.
i also had a kid ask me about the accuracy of 2 points. I moded the code some. I may not be what your looking forbut I think it will give you the idea.
Code:
range = 40;
closeness = 0;
function onEnterFrame() {
pointcode();
}
function pointcode() {
//this just makes the hero move for the test
hero._x += 10;
//checks to see if its in the radius well just the X
closeness = checkpoint._x-hero._x;
if ((arrow_._x>checkpoint._x-range) && (hero._x<checkpoint._x+range)) {
trace("good");
}
//checks to see a miss
if (hero._x>checkpoint._x+range) {
trace("missed");
}
}
you could add the y to get the all around checking. You can make the range 0 to be super accurate. This code was used to help make a DDR game so I think its good, being that DDR is all about checking checkpoints .
CEO OF
-
M.D.
 Originally Posted by Kianis
Hm, can't you use the dot product of the velocity vector and the distance vector between the two object ( from the red ball towards the center ). If it's negative
it will have passed it.
Hope I didn't misunderstand the question?
thats exactly it, thanks Kianis works a treat
-
self-portrait
 Originally Posted by mr_malee
thats exactly it, thanks Kianis works a treat
Great Glad I could help
-
Please, Call Me Bob
trying to grasp at what you're asking, you want to be able to do a hitTest succesfully against a bullet even when it travels really fast? i thought tonypa's covered this somewhere, oh well, let me think...
you ever heard of slope-intercept? you should have
slope=(dy-ry)/(dx-rx);
yintercept=dy-slope*dx; //i think?
if(Math.abs(yintercept)<=combinedwidths){
if(dx/Math.abs(dx)!=rx/Math.abs(rx)){
trace("pass?");
}
}
i think that'd be good enough, unless ive gotten it wrong somewhere, my brain's gottin' all fogg-ed upp-ed
btw malee, you're angle thing could actually be used for guard ai, if the angle difference is great enough, they would be like, hey!! very nice, they'd react to slow close objects or fast objects that were far away
Last edited by trogdor458; 12-16-2006 at 09:02 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|