• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Need Math Genius] How to perform bounce

Status
Not open for further replies.

Deleted member 219079

D

Deleted member 219079

I have unit going to x+1.0, y+1.0 every 1/32 seconds (so the moving force is 1,1). Then it get's to a point where the next point would be unwalkable. So I wanna modify the force so that it bounces relative to the angle.

Here's how it works now; my moving force is 1,1 and it sees relative position 1,1 is taken, so it inverts the moving force to -1, -1.
attachment.php


But the thing is it doesn't take angle into account:
attachment.php


It goes the wrong line and doesn't bounce to the correct 0.something , -0.something.

The problem 1 is how could the system even know what kind of obstacle there is, unit, destrcutible or unpathable terrain?

The problem 2 is I have no idea on how to calculate it mathematically:
For example like unit moving force is 10, 10, it sees tree blocking it, which is centered at relative pos 12,11.
attachment.php



So I guess it is impossible?
 

Attachments

  • omghelphelphelp.png
    omghelphelphelp.png
    10.2 KB · Views: 295
  • omghelphelphelp2.png
    omghelphelphelp2.png
    14.5 KB · Views: 224
  • omghelphelphelp3.png
    omghelphelphelp3.png
    4.7 KB · Views: 201
Level 12
Joined
Feb 22, 2010
Messages
1,115
Bounce Angle Question
http://www.thehelper.net/threads/deflection-angle.110528/

Problem 1, check what is there in given coordinates?Since neither of a unit, a destructible and unpathable terrain can be at the same place, there should be only 1 obstacle.And yes you need to check them 1 by 1, first check for terrain, then for unit, then for destructable or whatever order.And yes again you need to check all of these while moving unit to calculated point.

Problem 2, BEST solution for this is moving your objects with lower periods of course.If you observe any random game, you will see none of moving objects has a speed such that it is larger than an object in 1 period/tick.Yes there are alternative solutions for this problem but you SHOULDNT EVEN NEED them in the first place.
 

Deleted member 219079

D

Deleted member 219079

guess that I made it
JASS:
method collision takes Vec oV, F f returns nothing
            local real oldSpeed = SquareRoot(f.fv.x*f.fv.x+f.fv.y*f.fv.y)
            local real newAngle = GetDeflectionAngle(/*
            */x,           /* our x
            */oV.x,     /* obstacle's x
            */y,           /* our y
            */oV.y,     /* obstacle's y
            */bj_RADTODEG * Atan2(f.fv.y - 0, f.fv.x - 0)) //force's angle
            set f.fv.x = oldSpeed * Cos(newAngle)
            set f.fv.y = oldSpeed * Sin(newAngle)
            call oV.destroy()
        endmethod
f is the moving force i talked about, oV is the obstacle's x, y and z

I think that for those whose center I can't get - such as terrain, doodads - I will just reverse the moving force.

Thanks ceday, you're a genius ! :)
 
Status
Not open for further replies.
Top