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

Planetary Orbit Malfunction

Status
Not open for further replies.

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
I'm trying to create a space map and so far everything is going as planned except for one thing: planetary orbits.

In my map, I have planet-units and star-units; all the planets in planet (unit) group [x] are supposed to orbit star [x] by having them move to a point that is X distance from the star and then just adding 1 to the angle between the star and planet.

It works beautifully until the angle of the planet in relation to the star gets to ~180 deg. and from there it simply bounces between ~179 deg. and ~181 deg.

If I attempt to set the starting angle of the planet in relation to the star any higher than 180 deg., it will immediately set to 90 deg.
 
Level 6
Joined
Jul 25, 2005
Messages
221
I've come across a similar malfunction using angles, back when I was making a pet following its master... It did what it was supposed to do until it came to 180 degrees, then it stopped doing, well anything. I suppose you can try using the other move, facing point? that worked for my prob. Anyway, someone other than me will probably say something smarter so *delete message*. :cute:

I'm gonna use the pq formula to look smart:

(p/2)+- squareroot of (p/2) to the second power + q

EDIT: pq formula ftw :D
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
Ahh. I never thought of facing angle, or the pq formula. Thank you sir :thumbs_up:. But I have another question: what if I have multiple planets of different orbit angles going around 1 star?
 
Level 6
Joined
Jul 25, 2005
Messages
221
I suppose you can use simple arithmetics? angle of the star + orbit change (orbit change using array for each planet accordingly), although it sounds too simple >.<
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
Got it working, sort of. It will only operate for 2 solar systems :angry:.
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
Try using variables or variable arrays.

That is exactly what I did just to get the second star system working. For reasons beyond my comprehension, it simply refuses to work for more than two solar systems. I couldn't be angrier at WE right now.
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
I'm not trying to berate your suggestion; I've already tried it.

Here is what I did just to get the 2 solar systems to work.

I set star [0] = Star 001 <gen>, star [1] = Star 002 <gen>, star [2] = Star 003 <gen>, and star [3] = Star 004 <gen>. Only the first two star variables wanted to work.

Now I set the variables inversely for a test: star [0] = Star 004 <gen> and star [1] = Star 003 <gen> and so on.

Guess who decided to work all of the sudden and who decided to stop working.
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
Event
>Every 0.01 seconds of game time

Conditions

Actions
>For every (Interger A) from 0 to 3, do (Actions)
>>Unit Group - Pick every unit in star_system [(Interger A)] and do (Actions)
>>>Set star_position = (Position of star [Interger A])
>>>Set distance = (Distance between star [Int. A] and picked unit)
>>>Set planetary_speed_differential = (100/distance)
>>>Make (Picked Unit) face (planetary_speed_differential +(Facing of Picked unit)) over 0 seconds
>>>Set planet_angle = (Facing on Picked unit)
>>>Move (Picked unit) instantly to (star_position offset by distance towars planet_angle)

This thing works semi-perfectly: it won't work for more than 2 systems and for some reason the planets all get randomly placed around the star the first time this trigger fires (no huge problem there).
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
I've had it on various speeds between 1.00 and .10 before I set it to 0.01; no change, the "2 system limit" still existed. The reason I had it on 0.01 is simply because I didn't know there was some kind of 'speed limit' for triggers; the game runs fine if it was even 0.00 (although everything happens to fast to be watched), I've tried it several times on a variety of maps with no issues.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
If that is your trigger, your map is doomed due to the ammount leaked

You have to remove the location leaks otherwise it will lag horiadly after a while of playing

Also reduce update speed to atleast 0.03 or above even. For an orbit system I may recomend JASS as it can be made a lot more efficently than with GUI and so your map will have even less processor overhead.

Currently be lucky it only supports 2 since if it supported more it would leak more and lag more.

Switching over to unit arrays and using X and Y values instead of locations with a combination of JASS could easilly make that system run smoothly with many solar systems.
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
2 Questions:

How exactly do I remove such leaks? I can't set the star_position variable to anything like "No point" or something.

Would you happen to know where I could find an orbit JASS function? I have absolutely no JASS skills.

EDIT: Actually, I have very little JASS experience, by very little I mean like I've never written a JASS function but I know what most of it is.
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
call RemoveLocation(udg_YOUR-VARIABLE-GOES-HERE).

Do I need a separate JASS script for that call action to work or is it an internal function thing? (If this first part is true, then you can tell I'm no master at JASS.)
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
Let me try again:

Event
>Time - Every 0.05 second of game time

Conditions

Actions
>For each (Interger A) from 0 to 3, do (Actions)
>>Unit Group - Pick every unit in star_system and do (Actions)
>>>Set star_position = (Position of star [(Interger A)]
>>>Set distance = (Distance between star [(Interger A)] and Picked unit)
>>>Set planetary_speed_differential = (100/distance)
>>>Unit - Make (Picked unit) face (planetary_speed_differential + (Facing of (Picked unit))) over 0 seconds
>>>Set planet_angle = (Facing of (Picked unit))
>>>Unit - Move (Picked unit) to (star_position offset by distance towards planet_angle)

>Custom script: call RemoveVar(udg_star_position)
>Custom script: call RemoveVar(udg_distance)
>Custom script: call RemoveVar(udg_planetary_speed_differential)
>Custom script: call RemoveVar(udg_planet_angle)

This trigger any better?
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Learn JASS. Don't do stuff like this in GUI (unless you know what you're doing, but you can't know what you're doing in GUI unless you know and are proficient in JASS, at which point you'd rather shoot yourself than do it in GUI...).

Then, you can either simulate gravity and have them orbit that way, or model it orbiting. I'd recommend the later, in which case just increment the angle by X radians each 0.03, and then use R*Cos(angle) for the X, R*Sin(angle) for the y, and you're done (use the X and Y to offset from the X and Y of the star). Note that you might want to, for various reasons, keep the angle between 0 and 2pi or something, or it could end up rather rapidly massive.
 

Orc

Orc

Level 4
Joined
Jun 11, 2008
Messages
85
Alright. Thank you everybody for your time and help. Perhaps my map will not be doomed after some tinkering in JASS.
 
Status
Not open for further replies.
Top