3 Replies Latest reply on Apr 2, 2007 7:40 AM by kglad

    help with bounce script?

      Okay, so i have written a small script (alot like those birds-eye car racing games that pretty much just handles a box as a car is the same way as the games do. but theres a problem, when the car hits a wall i multiply the acceleration value by -1 and the car bounces back fine, but if the box goes towards the wall at a dodgey angle sometimes it gets stuck on the wall(i use gskinners collision detection script/class which can be found by googleing the general keywords i just specified ), here's my script, mabye someone's used stuff like this and has debugged it already enough to know a solution?

      import com.gskinner.sprites.CollisionDetection;

      var walls:MovieClip = _root.attachMovie("walls_mc","walls1_mc",_root.getNextHighestDepth());
      var car:MovieClip = _root.attachMovie("car_mc","car1_mc",_root.getNextHighestDepth());
      var accel:Number = 0;
      var angle = 0;
      car.onEnterFrame = function(){
      var collision1 = CollisionDetection.checkForCollision(car1_mc. walls1_mc, 120);
      } else {

      some general if key.isdown statements that add to the variable accel and the variable angle.

      var angleRadians = angle*Math.PI/180
      var adjacent = Math.cos(angleRadians)*accel;
      var opposite = Math.sin(angleRadians)*accel;
      this._rotation = angle;

      you'll have to imagine that walls_mc is a movie clip containing 4 walls that go from (50, 50) to (500,350).
      and that my stage is the general 550*400 size. also the car_mc movie clip is a rectangle that is 85*25

      the thing is if a corner of the car hits the wall it bounces still but then if the accel value was not high enough it stays caught on the wall...

      anyone experienced this before?