HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Ship Movement Physics System in 2D

10-07-2007, 09:44 PM#1
Salbrismind
Hey, after a week and a half of writing calculations in my book and applying it to WE i finally finished the basic code (without all the arrays and such for the full game) of my physics system for my new map.

The system calculates the displacement of the ship every 0.03 as long as the player is pressing forward on the keyboard. In effect the ship can turn and move forward at any angle and any speed and the system calculates it all perfectly and submits the new data to the final trigger that takes the new speed and direction and moves the ship every 0.03 seconds.

The system is based off of the way ships move in the old Dos game "Star Control" where the player can't stop using backwards thrusters but can only turn and go forward.

Check it out: Movement Test(1).w3x

Don't mind the 2 new arrays i just added, one for the boolean to control the calculations and the other for speed per second. I was starting to alter the code to suit my map when i realized i should share my new creation with the forums. If you want, you can change the max speed by changing every instance of 15 with a variable or with the max speed you want. How much the ship accelerates is controlled by the "speedpersec" array and you can find the action to change it in the "Lock Camera" trigger.

Also if anyone can help me figure out how to lock the camera above the unit that would be appreciated.


Updates:

2007, October, 8th:
-Added MUI Functionality
-More accurately calculates the new direction
Attached Files
File type: w3xMovement Test(1).w3x (25.2 KB)
10-07-2007, 10:06 PM#2
Hey its X
Lots of fun to play around with. wish I wasnt so lazy that I wouldnt make this work for all of the players :S
10-07-2007, 10:13 PM#3
Salbrismind
Quote:
Originally Posted by Hey its X
Lots of fun to play around with. wish I wasnt so lazy that I wouldnt make this work for all of the players :S

I'm doing that right now, or at least for my friend and I to play. I'm changing all straight variables to arrays.
10-07-2007, 11:58 PM#4
MaD[Lion]
hm.. tere are systems for this kind of stuff u know :P they also support 3d
10-08-2007, 12:17 AM#5
Salbrismind
Oh? hmm... well i'm proud i could make the same thing without any help. Did you try this?
10-08-2007, 12:46 AM#6
MaD[Lion]
yes i did try, it is nice idea, just it is a bit weird, since the unit slide endless.

The other systems are alot more complex and allow lot more thing tho.
10-08-2007, 12:53 AM#7
grim001
Well good job on the final result, it controls smoothly...

The math is horribly ugly though, vectors are made for this kind of thing and would make the code about 10 times shorter and more efficient.
10-08-2007, 01:15 AM#8
Salbrismind
Quote:
Originally Posted by grim001
Well good job on the final result, it controls smoothly...

The math is horribly ugly though, vectors are made for this kind of thing and would make the code about 10 times shorter and more efficient.

Hmm? How i could make it better? What do you mean by vectors?
10-08-2007, 01:22 AM#9
Pyrogasm
Ah, the wonders of vectors. Vectors on Wikipedia
10-08-2007, 01:33 AM#10
PenguinEmperor
Yup. Vectors.

10-08-2007, 02:14 AM#11
Salbrismind
Updated: I don't your way is possible/more efficient in my case because of the speed limit ships need to have. The problem with what your suggesting comes into play when i try to set the speed limit to my desired amount. Because i have only x and y i would first need to find the distance from the ships position to the new point. After that i need to make sure the angle the ship will face won't change when the speed changes. Now using both distance and angle i would then have to find new coordinates that suit the conditions of angle and distance.

If you can give me a low code line amount way to do this I will use it otherwise I am keeping my system.
____________________________________________________________________________
This I understand but what in my code could i do to make it more efficient.

After thinking about this for a second, i think i understand your suggestion.
Am I right to think you want me to remove the calculation of the third side of the triangle and it's angle? And then isn't just take the x and y i already gather and just put that into the next trigger?

Such that:
Trigger:
Unit - Move ship[1] instantly to ((Position of ship[1]) offset by (x[1], y[1]))

I'll test what i think you meant right now.
10-08-2007, 02:46 AM#12
PipeDream
Very fun smooth motion; quite a counterexample for the GUI nay sayers (i.e. me).
You are in fact already using vectors, what they mean is to focus on a cartesian basis(x,y vs. r,theta) using structs / vJass or just a few globals. If you translate to JASS it will probably just fall out and be obvious.
10-08-2007, 03:01 AM#13
Salbrismind
Thanks for the praise. I see now, but my position stands, the max speed is a difficult and over complicating issue. Until my present system fails to meet my criteria i will keep it, thanks for all your suggestions and comments!

I will be posting my map recruitment and synopsis soon for those that might be interested now in my project. Now that the basic system is made i need a few people to help me make triggers for all 10 players. This means copying and pasting and changing all the index counts to the player number. If anyone would like to help just pm me and i'll give you rep and put your name on the credits list.
10-08-2007, 03:39 AM#14
PenguinEmperor
Okay, I jsut played it, and it was freaking epic.

Just a few things:

-Is it MUI?

-You can't stop.
10-08-2007, 04:10 AM#15
Salbrismind
Quote:
Originally Posted by PenguinEmperor
Okay, I jsut played it, and it was freaking epic.

Just a few things:

-Is it MUI?

-You can't stop.

As of yet only one player can player at a time but as we speak i am working on getting the triggers for player 2 up.

Not being able to stop is a deliberate feature because in the map there is no used for stopping. Some ships will be slower and will go very slow and can sit and just rotate but stopping isn't really apart of the game. It's just like in most fps games, you don't stop moving because people can hit you easier.

Again i implore you to help me get all players up and running. To do this i need maybe 2 or so people to spend 20 minutes copying and pasting the triggers then change all index's to another player (10 players in all).