Here's my thought. Let's say pylons are positively charged and a marine is also positively charged. I want the marine to move as if he is being pushed with a force equal to 1/(hisposition-pylonposition)^2 (repelled by the pylon). So, slower when he walks toward the pylon, faster when he walks away from the pylon. How would one go about doing this? Would you have to constantly change the marine speed after every request for him to move(and during his movement) or can you change his position explicitly given the force he's permitted to exert and the forces he experiences from pylons.
Force effects. I don't know how much detail you need, but just create a behaviour that does a periodic search. Make sure you assign some attribute to positively charged units (ie flag them all as radars, biological, psionic or something) and have the search effect filter for those units. Then have the search filter apply a force effect. This will cause the pylon to constantly push any unit with your custom positive charge tag away.
If you want attraction instead, then use a negative value in the force effect.
Ok, I was just looking into modeling it off of the mothership vortex but I don't understand where the targets of the vortex are defined (to what distance away from the mothership-vortex units are affected and what types of units) and how it determines how much force they receive (and therefore affects their movement).
Force effects. I don't know how much detail you need, but just create a behaviour that does a periodic search. Make sure you assign some attribute to positively charged units (ie flag them all as radars, biological, psionic or something) and have the search effect filter for those units. Then have the search filter apply a force effect. This will cause the pylon to constantly push any unit with your custom positive charge tag away.
If you want attraction instead, then use a negative value in the force effect.
Ok, I was just looking into modeling it off of the mothership vortex but I don't understand where the targets of the vortex are defined (to what distance away from the mothership-vortex units are affected and what types of units) and how it determines how much force they receive (and therefore affects their movement).
Target - Location +
This is where the effect originates from (totally contradictory from it's name...). 9 times out of 10 you want this set to "Source" unless you have a very specific reason for not doing it (ie making missiles launch backwards or something silly).
Unit - Unit +
And this is the impact point. Just leave this as the default "Target" setting unless, again, you're after backwards missiles.
You're welcome! I'd like to add that if you want varying degrees of repulsion dependent on distance, then you'd need multiple search effects with differing force values and radii.
There's no way to use a trigger(function) to compute the distance between them and calculate the needed strength then call an effect where its strength is the result of that function?
Yeah, there is. It won't work very nicely, but if you only have 1-2 units that need to be repelled, then it'll be okay.
Firstly, do as I said above with the force behaviour. Set the force applied to 0.01. Now create an upgrade with 100 levels. Have the upgrade increase the force applied by 0.01.
Now to your trigger. Have the trigger calculate the distance between the marine and the pylon, convert it to a percent and set the level of the upgrade to whatever percent your trigger churned out. Requires small amounts of maths skills.
This is a very clumsy solution but will work. Don't use this if you have many different units that need to be affected by this system.
Alright, thanks. I'm looking into doing this as a project for my physics class and I think it would be a lot more interesting if it could be a fairly legitimate game so probably the trigger way you were describing wouldn't be the way to go. How do the force effects determine how much acceleration they cause on the units?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Here's my thought. Let's say pylons are positively charged and a marine is also positively charged. I want the marine to move as if he is being pushed with a force equal to 1/(hisposition-pylonposition)^2 (repelled by the pylon). So, slower when he walks toward the pylon, faster when he walks away from the pylon. How would one go about doing this? Would you have to constantly change the marine speed after every request for him to move(and during his movement) or can you change his position explicitly given the force he's permitted to exert and the forces he experiences from pylons.
Force effects. I don't know how much detail you need, but just create a behaviour that does a periodic search. Make sure you assign some attribute to positively charged units (ie flag them all as radars, biological, psionic or something) and have the search effect filter for those units. Then have the search filter apply a force effect. This will cause the pylon to constantly push any unit with your custom positive charge tag away.
If you want attraction instead, then use a negative value in the force effect.
Ok, I was just looking into modeling it off of the mothership vortex but I don't understand where the targets of the vortex are defined (to what distance away from the mothership-vortex units are affected and what types of units) and how it determines how much force they receive (and therefore affects their movement).
Very interesting, thank you for this Eiviyn.
Target - Location +
This is where the effect originates from (totally contradictory from it's name...). 9 times out of 10 you want this set to "Source" unless you have a very specific reason for not doing it (ie making missiles launch backwards or something silly).
Unit - Unit +
And this is the impact point. Just leave this as the default "Target" setting unless, again, you're after backwards missiles.
You're welcome! I'd like to add that if you want varying degrees of repulsion dependent on distance, then you'd need multiple search effects with differing force values and radii.
There's no way to use a trigger(function) to compute the distance between them and calculate the needed strength then call an effect where its strength is the result of that function?
Yeah, there is. It won't work very nicely, but if you only have 1-2 units that need to be repelled, then it'll be okay.
Firstly, do as I said above with the force behaviour. Set the force applied to 0.01. Now create an upgrade with 100 levels. Have the upgrade increase the force applied by 0.01.
Now to your trigger. Have the trigger calculate the distance between the marine and the pylon, convert it to a percent and set the level of the upgrade to whatever percent your trigger churned out. Requires small amounts of maths skills.
This is a very clumsy solution but will work. Don't use this if you have many different units that need to be affected by this system.
Alright, thanks. I'm looking into doing this as a project for my physics class and I think it would be a lot more interesting if it could be a fairly legitimate game so probably the trigger way you were describing wouldn't be the way to go. How do the force effects determine how much acceleration they cause on the units?