• 🏆 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!

Physics Simulation

Status
Not open for further replies.
Level 7
Joined
Aug 13, 2007
Messages
309

* click the picture to download the map
When playing my map type -order to open up my order form to order units which will have physics applied to them at creation and be dropped from the air. When you have a marine selected type -weapon # (1-6) to change the weapon he uses causing him to fire different projectiles when you attack ground with him. Open up the map in the editor and take a look through the scripts to find out more.

All my tl;dr write ups have been largely ignored so I'll keep this post as short as possible.

What... does my physics simulation need?

I know it needs position, velocity, acceleration, gravity, mass, friction, and some other stuff. What am I missing?

Am I being clear enough? I don't really know what forces are involved...

What I am trying to do is make a ball pit. I shall fill the ball pit with a whole lot of balls. The balls when dropped from the air bounce off of the ground and they also always bounce off of / collide with each other. They should also be able to slide towards the middle of the ball pit (or over the edges if they escape my ball pit of course) based on the angle of the terrain. The balls will be of random size and I guess that would mean varied mass. I think said ball pit example would involve about every kind of motion I want to do with my physics simulation... unless vehicles and bipedal ground units require some special forces that projectiles don't use... like maybe traction, although traction is probably just friction I think.

Ultimately I intend my physics for simulating the motion of any projectile (grenades, bullets, flame, balls, etc.), vechicles (both flying and ground ones), and units (such as marines) moving about my map.

Some things I have got already working though not everything is working properly, probably because I'm missing some things I need, or maybe I'm just doing stuff like my sliding wrong.

Related older threads: What Variables are Required for Physics? and Physics Simulation

 

Attachments

  • Blue Physics 0.11.SC2Map
    673.5 KB · Views: 225
  • Physics Simulation v0.11.png
    Physics Simulation v0.11.png
    128.2 KB · Views: 537
Last edited:
Level 7
Joined
Aug 13, 2007
Messages
309
List of Known Issues
Please help with solving them wherever you can
  • Sliding just doesn't work the way it should. Maybe it's too strong or maybe I need to attach a slipperiness value to each unit. Maybe I'm doing it wrong altogether.
  • Projectiles do not deflect off of the terrain. They bounce upwards like they should but the xy part of the bounce is not done. If someone could explain how to do this I would really appreciate it... DrSuperGood told me something really vague and from what he has said I reckon it's done in a similar way to the way I do sliding but I could be wrong.
  • The order menu is not complete yet. I have yet to add the scroll and page buttons so that players can see more than just the first 16 options. I don't need any help with this though as I know what I'm doing here.
  • Friction is WAY TOO STRONG for most projectiles. After sliding a very small bit they quickly come to a stop. Also friction is a constant yet I think it should vary between different physics objects so maybe the right way to do that is to give a different friction value to each unit so some can slide along easier and others can't...
  • My simulation does not use mass. I do not know how to use mass or where to use it.
  • No air drag. I read somewhere that this is required to prevent projectiles from accelerating infinitely; if you have air drag they will reach a terminal velocity and not move any faster. I am not sure however if this force is significant enough and the map big enough as to allow a projectile to travel a distance where air drag actually matters for the purposes of my simulation.
  • Could be other things I'm missing that I don't know of besides mass and air drag. Anyone know?
    [*]It seems that when a projectile collides with an enemy it does damage if that unit is owned by a player which considers you an enemy, however you could be unallied to it and as long as its owner is an ally you won't be able to hurt it. I should change my alliances system so that in the future players can't abuse this by allying a player so they don't get hurt then going up to them and attacking them.
    [*]If everyone in the game is allied from the start, using PlayerSetAlliance(); does not change anything. Like the player you just unallied, his units appear to be unallied and when you hover over the mouse / selection circle is red, but your units don't automatically attack them and the search area doesn't behave buff differently. If however everyone is unallied from the start, then PlayerSetAlliance(); magically works now and you can use it to ally/unally players. Units will attack but the search are is still unchanged. This makes no sense and is retarded. The search area buff doesn't realize when alliances have changed unless you change alliances through frame 24 (the default alliances menu Blizzard provides). The PlayerSetAlliance() function should have changed everything but Herp Derp Blizzard fails.
  • Ignore both of the above grey entries. I have since fixed the problem, it's really weird, but you have to set all alliance fields or it messes up.
  • When a projectile collides I need to take into account the distance between the projetile and the unit it's "colliding" with to make sure I don't have small projectiles like bullets doing damage or being effected by every unit within a 1.0 search area radius. I already do this for height (z) but not x and y.
 
Last edited:
Wow.. this is probably one of the most, if not THE most, impressive displays of physics I've ever seen in a mod of either Wc3 or Sc2.

I'll tell you what I noticed wrong, but you probably already know them:

When an object collides with an angled surface, instead of bouncing in the direction the surface would intend it to, it continues on it's forward path.

When an object lands on a hill, instead of having an increased acceleration (because it's on a downward slant) it simply slows.

But.. either way.. very impressive. Idk what you're planning on doing with such an engine in the future but whatever it is will most likely be very enjoyable to play.

Keep up the good work.
 
Level 7
Joined
Aug 13, 2007
Messages
309
Wow.. this is probably one of the most, if not THE most, impressive displays of physics I've ever seen in a mod of either Wc3 or Sc2.
I feel so happy after your comment :D!

I'll tell you what I noticed wrong, but you probably already know them:

When an object collides with an angled surface, instead of bouncing in the direction the surface would intend it to, it continues on it's forward path.

When an object lands on a hill, instead of having an increased acceleration (because it's on a downward slant) it simply slows.

I am aware of both of these problems. Another problem is the sliding somehow needs to be adjusted so units can walk up the slopes easier. Maybe the sliding just needs to be weaker or the friction needs to be different for each unit and maybe I'm applying friction wrong. Perhaps I need a different equation entirely then what I'm currently doing I do knot know:
JASS:
            // ------- Friction
            gv_accelX[lv_cv] = gv_velX[lv_cv]*c_friction;
            gv_accelY[lv_cv] = gv_velY[lv_cv]*c_friction;
            gv_velX[lv_cv] = gv_velX[lv_cv]*c_friction;
            gv_velY[lv_cv] = gv_velY[lv_cv]*c_friction;
            // ------- Sliding
            lv_slide   = WorldHeight(c_heightMapGround, PointWithOffset(lv_pt, -1.0, 0.0));
            lv_xOffset = -(lv_zw - lv_slide)*8*c_physicsTimerInterval;
            lv_slide   = WorldHeight(c_heightMapGround, PointWithOffset(lv_pt, 0.0, -1.0));
            lv_yOffset = -(lv_zw - lv_slide)*8*c_physicsTimerInterval;
            gv_accelX[lv_cv] += lv_xOffset;
            gv_accelY[lv_cv] += lv_yOffset;
            // Add sliding
            lv_pt = PointWithOffset(lv_pt, lv_xOffset, lv_yOffset);
            gv_posZ[lv_cv] = WorldHeight(c_heightMapGround, lv_pt);
Please if anyone knows what I'm doing wrong here or what I'm missing here tell me!!! I've been trying to get help with this for days.

But.. either way.. very impressive. Idk what you're planning on doing with such an engine in the future but whatever it is will most likely be very enjoyable to play.

Keep up the good work.

It partly depends on what models I can acquire. I'll be using this in my Impossible Odds map. There'll be vehicles which use gas and that you can run over enemies with, maybe even set up turrets on, and drop grenades from the passenger seat (like a Warthog), etc.

I also have flying vehicles which I'll be applying this too and they'll be able to do bombing runs and the explosions if they don't outright kill the unit will send them flying into the air while taking damage.

I will have a huge arsenal of weaponry with various effects such as flame damage, knockback, projectiles which can go through multiple units, physical damage (fall damage, damage caused by units getting knocked around), explosions, and anything else I might want.

In my game I generate the terrain randomly so it's different each time, and I have the difficulty fluctuate so there are moments where everything is really intense and the whole team of survivors can barely manage to survive (usually they don't unless they're all working together). Whenever the game ends it displays how long they all survived for and how many waves.

It's very challenging but I intend to make it very rewarding too; I shall save peoples highscores and whenever they get past a really hard set of waves (e.g. right now it's nearly impossible to make it to wave 30) then they unlock a new area aka they all get into a helicopter, fly away, and a whole new terrain is generated with a different theme; then they are deployed again and have to fight in this newly generated area and against new enemies.

Later on when players rm they will be able to load their progress and if enough of them have made it sufficiently far they (along with the n00bs tagging along) can start off at a higher level randomly generated area.

Impossible Odds is basically a game where you and some other marines are dropped off into various hostile situations in wastelands, forests, towns, fields, etc. and along with AI forces which can be called in or may just show up on their own at various times fight against impossible odds to survive againt numerous enemies who for the most part are hell bent on killing you. I intend to give players maximum freedom as to what they can do while deployed and along with the whole scenario being randomized each time there'll be many different strategies players can use and things in the environment they could potentially utilize to survive.

There won't be any stupid forced objectives like in most campaigns other than whatever naturally seems like a good idea to the players. For example they may decide they should protect a group of AI allies so they have their help longer before they are killed, they may consider getting gasoline or repairs for a vehicle to run more important, they could consider building their defenses top priority and rig a place with explosives, seek out medical supplies to heal wounded allies, find ammo caches or call in supplies, fixing a radio tower to so they can call in bombing runs and other things, or maybe a player might decide they just want to screw off and go on a one man suicidal rampage finishing it off with blowing themselves up like in I Am Legend then waiting for a respawn. There'll be a lot of things to keep in mind and choices to be made but it's all up to the players what they do or don't do.

There are an infinite number of waves btw.

That's not the only thing I intend to use my physics for though. I have another project called Fort Wars which I want to remake in SCII. It's a medieval game so I'll need custom models for it... that's why I haven't started on it yet v.v. It is very hard to acquire the help of modelers.

Anyways in Fort Wars people will be able to use bows, crossbows, slings, javelins, spears, burning oil, etc. and many melee weapons too. Agricultural production is important and people can raise livestock (ever played Sheep Farmer 3, 2, or 1 on WCIII? It's like that but more advanced) and plant crops which actually grow and reproduce and will even have some mendelian genetics.

There are no specialized units in Fort Wars instead you have a civilian populace which continuously grows as they mate with each other and raise families and you can set up buildings which automatically recruit them for various tasks and if you have the tools/weapons the AI will find them and use them. So you can equip your peasants with weapons of war, stone masonry tools, agricultural equipment, wood carving tools, fletching, etc. to produce everything you need.

As your population grows it becomes necessary to continuously expand to prevent famines and acquire more materials to keep your economy going; thus war breaks out between the opposing players and their forts. The game starts with two teams however players can break away from the main fort for any reason they want and form their own settlement elsewhere and create new alliances.

It is also important to note that as in my WCIII Fort Wars, the peasantry reacts to your actions and is always rebellious; if you don't maintain law and order then their can be an uprising and entire subsections of your fort or even an entire settlement may be lost to their influence and you'll have to do something to stop it before their movement grows and they end up pillaging and burning everything in total anarchy. If the rebels are successful they may even set up their own state and periodically raid the forts of human players.

I'll be using my physics for catapults, ballistas, archers, etc. to send their projectiles and I hope to make it so players can garrison their troops on the walls as they defend their fort. Just imagine a big rock launched by a catapult hitting a wall damaging the wall and sending any archers and other units on there flying over the edges and getting killed. Imagine the epicness.

I couldn't have done all of that in WCIII but I will be able to in SCII :D. When I'm done my first project (Impossible Odds) and people see how awesome it is I think it'll be easier to acquire the help of modelers for my second project (Fort Wars).
 
All of those games sound absolutely amazing. I especially like the one about the Fort Wars. I myself was in the process of creating a game with three players, three planets and an explorable space. The idea was that the players need to maintain their planet (choosing when it is to rain, etc) and keep their planet in good status. If they keep it up then life will begin to form (basic critters, dinosaurs etc). Eventually if they do everything right the creatures will evolve to Homo Sapiens and the cycle of life begins, eventually ending in an advanced society with space ships etc and they can wage war on one another's planets.

The idea was that at first the whole 'naturing' process is to be done in single player and all information saved to banks. At a certain level (for example bronze age) they unlock they ability to play online. This is so players don't need to repeat the whole planet building process every game.
Players would have no control over the units themselves; only their surroundings and give them general direction (hostile towards this guy, not towards that guy) and I even got into things such as random natural disasters.
I ripped an asteroid model from WoW and applied it to the game. There is a 5% chance every 60 seconds that asteroids will randomly come to that part of space and bombard the planets (it shows the asteroids falling, hits and explodes, then leaves a crater behind, all which 100% work right now). There are also other random events such as worm holes, the sun exploding, alien attacks, etc etc).

However I decided so much work on my own would be too difficult so I left the random events and reworked the game to be more like a "Solar Conquest" game from Wc3 because I liked it so much.

At the current time I only need to finish the finer details on space-bearing units (the game operates in teams, not single units. So when you spawn a squadron of marines it makes 5 not 1 but also takes longer to build and is more costly. This is to eliminate alot of the micro-management needed in Sc2 because I want players to focus on other things). After that I'll add some unique units with custom models if I deem fit.

I can't say I'm much of an artisan when it comes to map-making (I operate in GUI triggers). I could never have implemented a system such as this (though I could easily figure out the equations, I absolutely love math) so I don't know how much of a help I'd be to you. I'm a bit of an amateur 2D artist so I could offer that much at least.

If you ever need help with any of your projects please feel free to ask. All 3 ideas seem fantastic. Also check out my game Nacht Der Untoten (built in the beta) which is on public release if you want a small idea of my mapping skills :p

As for your questions, if I knew more about Galaxy and could understand your Scripting I could probably be of more use.
The only thing I can suggest is yes you should apply an air drag because everything will look as if it's done on the moon otherwise (especially things that need to travel large distances before reaching it's target point).
Instead of giving each and every unit a different friction rating, just give them a class. For example.. heavy, medium, light or smooth, medium, rough. Though it'll take more scripting, you should probably also apply different friction ratings for the terrain that it's coming in contact with. For example dirt will cause a moving object to slow quickly because of the infinite small particles coming in contact with it, pushing it in different directions as the object comes in contact (a ball hitting sand will have a 100 particles pushing it one way, 100 more pushing it another way, etc) and the effect is very apparent.

Whether or not you choose to throw me on board or not; either way good luck.
I look forward to seeing your work in the near-future. Maybe (hopefully) it'll get games like Surviving Apocalypse off the top of the charts which nearly anyone could make (I still remember LoaP wc3 days -_-)
 
Status
Not open for further replies.
Top