so im trying to get a missile to 'reflect' off a wall, or even a unit, w/e its not teh in game mechanics im stuck on, its how to get a reflected angle.
there is a function of 'reflected point' but i just cant make sense of the values, ive tried putting in hard numbers to see what i should expect / want to happen, as well as all the variables of the missiles 'angle' the default angle of the wall (i was thinking possible 0 was horizontal or something, while 90 was vertical etc...) but im lost. so any mathematicians out there know the formula for getting a reflected angle?
like if something was traveling at 45 degrees and hits a vertical wall), it should come off at 135 degrees the other way.
then if something hits the wall at 10 degrees and hits a horizontal wall it would come off at 350 (-10 by GE numbers as they go 0 to 180, then -180 to 0) i beleive. the pattern here is obvious i think but i just stopped doing math a long time ago and cant think 'outside the box' anymore. any help???
I don't think that "reflected point" function is what you want. My guess on it would be that it gives you a reflected point based on a region, the whole map, or something like that.
Why don't do change it's direction yourself? You know what you want, 180 - the incoming angle (of course that's based off what your hitting).
thats a lot of if and ors if im thinking along the same lines. keeping in UNIT FACING mindframe.....
all bouncing off a horizontal wall going up;
if its going 45 it needs to come off at 315
if its going at 100 it needs to come off at 260
(pretty much 360 - angle)
all bouncing off a vertical wall going right;
if its going 45 it needs to come off at 135
if its going at 300 it needs to come off at 240? (im no good at math nemore...)
different than above. i dont like sloppy code if its easily avoidable, and this is avoidable with the right brain!
there must be a mathematical equation where 1 formula or whatnot works for all directions / walls etc... ive tried googling it, but all i get is physics homework and not just a formula chart :(
i was thinking about just breaking it up and moving the missile manually with sin/cos then just flipping the sign of the velocities depending on what side wall(s) it hits, but then the missile doesnt function with all the normal abilities/effects built in with the data editor, and i figure that would slow down the code for the map overall immensly compared to using a built in movement method when its not completely necessary... at least just yet... well thanks for the input neways, hopefully some1 will come along and say 'thats easy.... its....'
180 - (incoming angle AKA angle of missile or unit) +2 * angleof wall = outgoing angle
so the angle of wall is..... say its going right into a vertical wall @ 45 degrees (which it should reflect back at 135), the angle of wall would be 90 or 270?
ok so 90/270 must be for horizontal walls and 0/180 must be for vertical, i guessed wrong. i guess its just a starting point of reference. this appears to work.... but my brain is done too. if it doesnt work tommorow when i got time to implement it ill repost with any more pleas for help. THANKS! :)
For 1 equation, it's exactly as you said, however, this is impossible to implement in the Galaxy Editor as a single action. For one, I don't see a way to dynamically find the angle of a wall without using vectors (possible to implement, but I've been lead to believe vectors are a hassle). Second of all, I'm pretty sure the galaxy editor won't accept degrees above 360, which is what will happen when bouncing off of South or Eastern walls:
180 + 2 * angleOfWall - incomingAngle = outGoingAngle, where angleOfWall:
North = 0
East = 90
South = 180
West = 270
Note, however, that when angleOfWall > 180 (when hitting the South or East walls), outGoingAngle will be greater than 360, thus for the trigger, you'll need to check which wall it hits. It's impossible to come up with a single line answer for Galaxy Editor unless you use vectors rather than degrees, which, correct me if I'm wrong, isn't an easy thing to implement.
The simplest way to get this into the Galaxy Editor, assuming you are only checking horizontal and vertical bounces is:
I signed up to answer this. but I probably would have eventually anyway.
what you want is to find the normal of the wall. this is the angle that is perpendicular to the wall's surface. given that we have the normals for each facing:
South = 0 or 360 (GE will accept both)
East = 90
North = 180
West = 270
now for the formula. outgoing angle = incoming angle - 2*(incoming angle - normal of the wall)
where incoming angle is the angle the missile is facing +180 to get it's angle relative to the wall. this example uses missile direction of 120 (60 degrees east of north) and a wall facing west (normal = 270) with an expected result = 240 (60 degrees west of north)
theta = (120 +180) - 2*((120+180) - 270)
theta = 300 - 2*30
theta = 240
another example with missile facing 350 (10 degrees west of south) with wall facing north (normal = 180) and expected result 190 (10 degrees west of north)
theta = (350+180) - 2*((350+180) - 180)
theta = 530 - 2*350
theta = -170
this is a ludicrous result however GE knows what to do. add multiples of 360 until it becomes positive. (if you had an answer larger than 360 it would subtract)
theta = -170 + 360
theta = 190
please tell me if you want more explanation or if I've made any mistakes. I would also like to know if I've helped at all. good luck and have fun.
thanks for all the help guys. and glad to instigate someone that knows their angles to sign up and help us out. maybe we can throw you a bone back sometime!
it is easyer with vectors.
you need the ground vector (normalised) (2/3d)
and then add it to your bullet speed and scale it with -(1+b)*vecDot(velocity,terrainvec)
and b is the bounce factor (vecDot = vecX[id1]*vecX[id2]+vecY[id1]*vecY[id2]+vecZ[id1]*vecZ[id2])
This is a physics problem not a mathematician problem you should look up formulas of collisions. If you wanting the other object not to move then make sure it has an extremely large mass.
so im trying to get a missile to 'reflect' off a wall, or even a unit, w/e its not teh in game mechanics im stuck on, its how to get a reflected angle.
there is a function of 'reflected point' but i just cant make sense of the values, ive tried putting in hard numbers to see what i should expect / want to happen, as well as all the variables of the missiles 'angle' the default angle of the wall (i was thinking possible 0 was horizontal or something, while 90 was vertical etc...) but im lost. so any mathematicians out there know the formula for getting a reflected angle?
like if something was traveling at 45 degrees and hits a vertical wall), it should come off at 135 degrees the other way.
then if something hits the wall at 10 degrees and hits a horizontal wall it would come off at 350 (-10 by GE numbers as they go 0 to 180, then -180 to 0) i beleive. the pattern here is obvious i think but i just stopped doing math a long time ago and cant think 'outside the box' anymore. any help???
I don't think that "reflected point" function is what you want. My guess on it would be that it gives you a reflected point based on a region, the whole map, or something like that.
Why don't do change it's direction yourself? You know what you want, 180 - the incoming angle (of course that's based off what your hitting).
yeah, there is that way
thats a lot of if and ors if im thinking along the same lines. keeping in UNIT FACING mindframe.....
all bouncing off a horizontal wall going up;
if its going 45 it needs to come off at 315 if its going at 100 it needs to come off at 260
(pretty much 360 - angle)
all bouncing off a vertical wall going right;
if its going 45 it needs to come off at 135 if its going at 300 it needs to come off at 240? (im no good at math nemore...)
different than above. i dont like sloppy code if its easily avoidable, and this is avoidable with the right brain!
there must be a mathematical equation where 1 formula or whatnot works for all directions / walls etc... ive tried googling it, but all i get is physics homework and not just a formula chart :(
i was thinking about just breaking it up and moving the missile manually with sin/cos then just flipping the sign of the velocities depending on what side wall(s) it hits, but then the missile doesnt function with all the normal abilities/effects built in with the data editor, and i figure that would slow down the code for the map overall immensly compared to using a built in movement method when its not completely necessary... at least just yet... well thanks for the input neways, hopefully some1 will come along and say 'thats easy.... its....'
Think it's the following:
180° - (incomingAngle - angleOfWall) = outgoingAngle - angleOfWall
But I'm under sleep deprivation right now so I can't be sure ..
then that formula would look like;
180 - (incoming angle AKA angle of missile or unit) +2 * angleof wall = outgoing angle
so the angle of wall is..... say its going right into a vertical wall @ 45 degrees (which it should reflect back at 135), the angle of wall would be 90 or 270?
for 90 180 - 45 + 2(90) = basically 360 - 45 = 315
for 270 180 - 45 + 2 (270) =675 which would coorelate to 315
so both seem to work either way as GE should compensate and make the 675 into 315 automatically, so im going to try another number or 2;
vertical wall @ 10; 180 - 10 + 2(90) = 360 - 10 = 350 180 - 10 + 2 (270) =710 - 360 = 350
vertical wall @ 80; 180 - 80 + 2(90) = 360 - 80 = 280 180 - 80 + 2 (270) = 640 - 360 = 280
ok so 90/270 must be for horizontal walls and 0/180 must be for vertical, i guessed wrong. i guess its just a starting point of reference. this appears to work.... but my brain is done too. if it doesnt work tommorow when i got time to implement it ill repost with any more pleas for help. THANKS! :)
For 1 equation, it's exactly as you said, however, this is impossible to implement in the Galaxy Editor as a single action. For one, I don't see a way to dynamically find the angle of a wall without using vectors (possible to implement, but I've been lead to believe vectors are a hassle). Second of all, I'm pretty sure the galaxy editor won't accept degrees above 360, which is what will happen when bouncing off of South or Eastern walls:
180 + 2 * angleOfWall - incomingAngle = outGoingAngle, where angleOfWall: North = 0 East = 90 South = 180 West = 270
Note, however, that when angleOfWall > 180 (when hitting the South or East walls), outGoingAngle will be greater than 360, thus for the trigger, you'll need to check which wall it hits. It's impossible to come up with a single line answer for Galaxy Editor unless you use vectors rather than degrees, which, correct me if I'm wrong, isn't an easy thing to implement.
The simplest way to get this into the Galaxy Editor, assuming you are only checking horizontal and vertical bounces is:
North: 180 + incomingAngle
South: 180 - incomingAngle
East/West: 360 - incomingAngle
I signed up to answer this. but I probably would have eventually anyway.
what you want is to find the normal of the wall. this is the angle that is perpendicular to the wall's surface. given that we have the normals for each facing: South = 0 or 360 (GE will accept both) East = 90 North = 180 West = 270 now for the formula. outgoing angle = incoming angle - 2*(incoming angle - normal of the wall) where incoming angle is the angle the missile is facing +180 to get it's angle relative to the wall. this example uses missile direction of 120 (60 degrees east of north) and a wall facing west (normal = 270) with an expected result = 240 (60 degrees west of north) theta = (120 +180) - 2*((120+180) - 270) theta = 300 - 2*30 theta = 240 another example with missile facing 350 (10 degrees west of south) with wall facing north (normal = 180) and expected result 190 (10 degrees west of north) theta = (350+180) - 2*((350+180) - 180) theta = 530 - 2*350 theta = -170 this is a ludicrous result however GE knows what to do. add multiples of 360 until it becomes positive. (if you had an answer larger than 360 it would subtract) theta = -170 + 360 theta = 190
please tell me if you want more explanation or if I've made any mistakes. I would also like to know if I've helped at all. good luck and have fun.
thanks for all the help guys. and glad to instigate someone that knows their angles to sign up and help us out. maybe we can throw you a bone back sometime!
it is easyer with vectors.
you need the ground vector (normalised) (2/3d)
and then add it to your bullet speed and scale it with -(1+b)*vecDot(velocity,terrainvec)
and b is the bounce factor (vecDot = vecX[id1]*vecX[id2]+vecY[id1]*vecY[id2]+vecZ[id1]*vecZ[id2])
ok your bouncing stuff off walls.
Have you come up with a way to rotate the model itself in flight?
Im not talking about facing...
you mean the actor message (set rotation)? no i saw thread about it (not yours) with an example but it doesn't really works
@ezbeats: Go
This is a physics problem not a mathematician problem you should look up formulas of collisions. If you wanting the other object not to move then make sure it has an extremely large mass.
Lawl. Look at how old this thread is, and when last OP was online.
/Facepalm