• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Vehicle Physics

Status
Not open for further replies.
Level 19
Joined
Oct 29, 2007
Messages
1,184
I'm making a map with vehicles. The vehicles are arrowkey controlled, which automaticly makes the physics a hard part. What I need help with is creating a method for detecting when a vehicle crashes. I currently only have one location for detecting if the vehicle crashes or not, which is located in the middle of the vehicle model. The attachments show how this fucks up.

Got any idea how can I make a realistic crash system without the vehicle being magically pushed 2-3 yards inside the wall? Cause that's where it crases now. I saw a map created by Bob666 which had a realistic crash system, but I can't find him, so that's why I'm asking here.


PLEASE DON'T HELP ME WITH THIS ANYMORE. I'VE DECIDED NOT TO INCLUDE VEHICLES IN MY MAP ANYMORE.
 

Attachments

  • Inside the wall.jpg
    Inside the wall.jpg
    122.5 KB · Views: 190
Last edited:
Level 8
Joined
Nov 9, 2008
Messages
502
Every 0.1 make a group of units in range of that unit, count the units in the group and if > 0 it has collided. Fidlle with the range to get the right distance.

The you can always specify the facing angle of that unit and realisticly set the distance for side collisions (which would be smaller seeing as that unit is longer than it is wide).

Maybe it's not most efficient. If not then I'm intrigued to know what is better.
 
Level 19
Joined
Oct 29, 2007
Messages
1,184
Yeah I already did that. The problem was that the edges of the vehicle still went through the wall. : < Anyway I've decides not to have vehicles in my map anymore because they were too 1337. Thanks anyway. : )

Could a mod please close this thread?
 
Here you go:

JASS:
function crash takes unit u, real dist, real dir returns boolean
    local location l1 = GetUnitLoc(u)
    local location l2
    local real a = GetUnitFacing(u)+dir
    set l2 = Location(GetLocationX(l1) + dist * Cos(a * bj_DEGTORAD), GetLocationY(l1) + dist * Sin(a * bj_DEGTORAD))
    if IsTerrainPathable(GetLocationX(l2), GetLocationY(l2), PATHING_TYPE_WALKABILITY) then
call RemoveLocation(l1)
call RemoveLocation(l2)
set l1 = null
set l2 = null
return true
else
call RemoveLocation(l1)
call RemoveLocation(l2)
set l1 = null
set l2 = null
return false
endif
    //return
endfunction

Then paste this in your trigger:


  • Custom script: if
  • Custom script: crash(MyUnit, MyDistance, 0.) == true
  • Custom script: then
  • Unit - Order (Last created unit) to Stop
MyDistance will be the length of your car. If you want a more precise system whith box collision, i can implement two extra polar projections from l2 to mark the corners, but this will do for now.
MyUnit is your vehicle, and 0 is the direction you whish to check in (deafult is unit's facing).
180 would make a backwards collision check.

Note that i haven't tested this and it's not sure to work, but i guess it should.


EDIT: Dammit!! Did i just do all that in vain? :O
 
You did, and holy crap why did you use locations?

In combat zone nazgul set all units collision size in a hash table and checked distance between the vehicle with all units around it within (that vehicles) collision.

Yes, indeed creating and destroying locations like that is very unefficient. But since 1.24 is coming up i don't dare to use hash tables, and besides i figured i'd make it easy to handle for someone whith little or no knowledge of jass.
I could make it so that a car struct is created for every car, but then it would require JNGP. I dont want to assume anything.
 
Status
Not open for further replies.
Top