• 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 help in getting some angles right for ricochet

Status
Not open for further replies.
Level 23
Joined
Oct 20, 2012
Messages
3,075
I might be thinking of something impossible here, but heck it's still worth asking.

What I'm trying to do is make a hooking spell that can ricochet when it hits the rock destructible. Yeap, my hook works, it's already fully MUI and it's already the plain old hook spell seen in thousands of maps already. The only problem I have right now is getting the actual ricocheting to work.

222907-albums6224-picture83882.png

(Awesome illustration. Cool)

The blue dot is the caster, black dot is the rock destructible. Purple line is the initial projectile direction whilst the orange line is the direction after the projectile ricochets.

Yes, I definitely can do this if I have the red line but I don't. That's the reason I'm here. I need help from you smarter people to help me get this right. How do I get those angles (green lines)? How do I set the direction of the orange line?

How?

HOW!? :ogre_rage:
 
Level 5
Joined
Feb 17, 2011
Messages
95
As i recall, for your picture, it is:
tan(a) = vx / vy

Correct me if i'm wrong, but for the red line, i don't think you can find its relative angle, since you are looking at caster and rock as a points/dots. But you could go around it by using some preplaced red lines, for example x and y, or more of them (0, 45, 90... degrees), and use whichever has the smallest angle of incidence. It's not the brightest solution.

Edit:
Another thought. If you look at the rock as a circle (and not a point) around its location, you could calculate where your hook's path cuts that circle and then use tangent line of the circle in that point as a red line.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
The problem is determining the normal required for the reflection operation. This is usually done in real games as part of the physics/collision process since you need to use deterministic collision geometry that is separate from the local graphic geometry.

In WC3 the best you can do is approximate such normal angels. If you are only dealing with 2D space then you can simply use the pathing map to determine collisions and the normals will be square (multiples of 90 degrees) based on how the pathing map is square. If you want a slightly better model or need 3D reflection then you can use a sphere based collision model where by each object is given a collision sphere which you read the normal from. More complex shapes can even be used on an object by object basis but this becomes increasingly complex and more computationally intensive to resolve.

Once you have your surface normal at the point of collision, you work out the angle difference between the incident angle and the normal angle and then subtract that from the normal angle (reflect it realitive to the normal angle).
 
Level 12
Joined
Nov 3, 2013
Messages
989
Bouncy hooks like in Pudge Wars?

Wouldn't it work to check in the loop when the hook "collides" with the object and have an if statement to check if it's a valid target and if it isn't take angle between the invalid target and where the hook came from originally?

Doesn't seem super complicated to me unless Im missing something.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Isn't this just a normal 2d reflection?We know where the collision has happened(usually this is the position of collider unit) and we know the position of rock, this means we know center of rock.(assume rock is a circle).Angle between center of rock and collide position will give us normal angle?Not?

We have 3 things we need.

The direction object coming from (usually this is unit's facing, but not always)
Collide position (we can assume this position of unit)
Center of rock
 
Level 23
Joined
Oct 20, 2012
Messages
3,075
Bouncy hooks like in Pudge Wars?

Time to dump this crap I guess. I didn't there's already a spell like this in those crap maps.

Isn't this just a normal 2d reflection?We know where the collision has happened(usually this is the position of collider unit) and we know the position of rock, this means we know center of rock.(assume rock is a circle).Angle between center of rock and collide position will give us normal angle?Not?

We have 3 things we need.

The direction object coming from (usually this is unit's facing, but not always)
Collide position (we can assume this position of unit)
Center of rock

Yeah I kinda figured it out already, all I needed was some sleep to figure out what I'm doing wrong. Thanks anyway.
 
Status
Not open for further replies.
Top