View Full Version : Collision detection help

threE deE
10-06-2003, 12:09 AM
I have this code (with some help from the Maze.fla sample).
This code has been applied to the "wall" mc that moves and detects the player's mc. This works but the detection for angled edges on the walls is a bit dodgy and it moves the player back to far from the wall which makes the movement skippy. how would i fix the hittest code to get smooth close collision detection for a topdown view run around game??

with (_root.player){
angle = 5
spd = 1.5

// Move Forward
if (Key.isDown(Key.UP)){
_x += spd*Math.sin(_rotation*(Math.PI/180))
_y -= spd*Math.cos(_rotation*(Math.PI/180))
// Move Backward
if (Key.isDown(Key.DOWN)){
_x -= spd/2*Math.sin(_rotation*(Math.PI/180))
_y += spd/2*Math.cos(_rotation*(Math.PI/180))
// Turn Left
if (Key.isDown(Key.LEFT)){
_rotation -= angle
// Turn Right
if (Key.isDown(Key.RIGHT)){
_rotation += angle

if (wallz.hitTest(getBounds(_root).xMax, _y, true)) {
_x -= spd
if (wallz.hitTest(getBounds(_root).xMin, _y, true)) {
_x += spd
if (wallz.hitTest(_x, getBounds(_root).yMax, true)) {
_y -= spd
if (wallz.hitTest(_x, getBounds(_root).yMin, true)) {
_y += spd

threE deE
10-06-2003, 08:54 PM
hello?? ive posted this on five forums and noone bothers to help me.

10-13-2003, 11:07 AM
Hi, unfortunately I canīt help you as Iīm a newbie but I can tell you that people here is very helpful and, if you didnīt receive any answer may be is because no one knows it.

Just be a little patient.

(if you want some collision help try to contact the argentine rugby team. Maybe they can tell you something about colliding agains aussies:p )