• 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.

Best way to detect frontal obstacle collision

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi.

Well I just want to know what would be the best way to detect a frontal collision with an obstacle. To a better understanding of what I mean, look at the pictures. The big red circle is the obstacle, the blue circle is the player, and the blue arrow points the direction the player is moving to:

cap01n.jpg

cap02o.jpg


This is meant for a race-type minigame I want to include in my main proyect. The player controls a racer, and must run through a circuit with obstacles, and things like that. The objective of the game is to get through the circuit in the less possible time, and I want the player to knock back and lose time if he collides with an obstacle, but ONLY if he is running towards the obstacle itself. In other words, I want to make it a bit realistic.

I thought about creating a region over the obstacle, keeping a dummy unit at a small distance from the player in the direction he is facing, then activating the knockback when the dummy enters the region, but I don't think this is too effective.
Do you have any ideas?

Regards
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I have some experience making maps like this, my method was to use a bit of Newton (II & III) mixed in with the theoretical particle approaching EM field model - that the force (hence acceleration) increases the closer you are to the object.

Basically:
Periodic trigger that checks distances, and accelerates the player directly away from the object based on distance to object.
This will be quite inefficient if you intend to use many round obstacles, but here's a simple way to implement it:

1. Give the obstacle Permanent Immolation with 0.1 period (it's either duration or cooldown, not sure)
2. Trigger event - unit takes damage
Action - move triggering unit away from damage source
 
Level 9
Joined
Apr 19, 2011
Messages
447
I have some experience making maps like this, my method was to use a bit of Newton (II & III) mixed in with the theoretical particle approaching EM field model - that the force (hence acceleration) increases the closer you are to the object.

Basically:
Periodic trigger that checks distances, and accelerates the player directly away from the object based on distance to object.
This will be quite inefficient if you intend to use many round obstacles, but here's a simple way to implement it:

1. Give the obstacle Permanent Immolation with 0.1 period (it's either duration or cooldown, not sure)
2. Trigger event - unit takes damage
Action - move triggering unit away from damage source

Maybe I'm understanding wrong your method, but you're telling me to give Immolation to the obstacles, and then knock back the player when it receives damage... But that would knock back the player no matter what direction is he facing...
Sorry, maybe I misunderstood what you said. If that's so, could explain it with a bit more detail?

Regards
 
Level 9
Joined
Apr 19, 2011
Messages
447
The player will be always advancing, but with the cursor keys he can move to the right of to left, so he can avoid obstacles. So said, being near an obstacle does not mean that the player is colliding with it. It only means colliding if the player is near the obstacle AND facing to it or to a part of it.

It's a bit hard to compare angles, because obstacles are actually created with doodads, they are parts of the terrain. I will have to create a dummy unit for each of the obstacles, place it inside, and then test a lot of times to find a suitable angle to compare. In my opinion, it would be a long and hard work.

Regards
 
Level 9
Joined
Apr 19, 2011
Messages
447
On second thoughts, how about this: check if walkability is off (pink pathing map) at a point in front of the unit.

I'll give a try to that. I would have to check with a loop over time, and I really didn't want that, as I already have a high number of triggers running over time, but I could create regions around the obstacles, and activate the checking only while the player is inside those regions. Then, I would have to use pathing blockers inside the obstacles.
Is this a reasonable approach? I think I'll try it and see what do I get.

Regards
 
Status
Not open for further replies.
Top