I am working on a snowboarding game, And have two points of collision detection on the board:
[COLOR=Red]x[/COLOR]-----[COLOR=Red]x[/COLOR][LIST]
[]One at the [COLOR=Red]Front[/COLOR] of the riders board
[]One at the [COLOR=Red]Back[/COLOR] of the riders board[/LIST]These 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:
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:
this.hitTest(backX, backY, true)
which is placed on the ground movieclip (what the snowboarder is riding on)
Can anyone suggest a better way of doing such collision checking, or how to account for rotation? is localToGlobal() the answer?
Cheers for any help.