Hey guys, I'm wondering if it's possible to make a system that drains "fuel" (energy) from a unit based on how far the unit has travelled. So let's say that the unit has traveled 10 yards or whatever measuring unit we're using, then the energy will be drained by 1 per yard. Ofcourse the fuel should be able to be refilled, otherwise the vehicle stops, but I'm pretty sure I can work that part out myself. I'm using this in a TPS engine, I've already made it possible to enter/exit vehicles fluidly and to control them smoothly, thought the fuel system would be a great asset to the vehicle part of the map. Since I'm using it in a TPS engine, I have BossBars to display the energy/fuel (which don't match the actual energy of the unit but that doesn't matter) so it doesn't have to drain energy but rather just set decrease the bar with 1 every time the unit travels say 1 yard or whatever.
Thanks in advance, any help or advice greatly appreciated!
I KNOW I have seen another topic asking about this same thing, I just can't seem to find it. I think your answer lies in data though, through validating if the unit speed is >0, and if so, allowing a behavior to trigger that decreases energy periodically. I know that may not be the complete answer you were looking for, but try searching the forums - I know I've seen this topic before.
If you want to go for a trigger approach, here are a few ideas for you:
- Have a periodic trigger
- Have a point-Variable
- At first, compare the current position with the position saved in the point var
- Calculate distance --> Fuel cost
- Always save the position of the unit into the point var AFTER comparing the distance
- Repeat
Make sure to have at least a 0.5 second interval, since for sure its possible for the unit to travel back to its origin, what would lower the distance. You can avoid this with a check interval <= 0.5 seconds. The smaller the interval, the more accurate this will get.
Managed to fix it using triggers :D Is there any way to make the unit "Freeze" with triggers? Since now, even if the unit can't move when the fuel is run out, the unit still plays his Stand animations and such.
Why don't you just disable stand animations altogether? If your unit is using fuel, and figet animations don't use fuel anyway, why even have them?
Well it would be nice to have them there when the vehicle has cargo and stands still, sorry but how do I remove specific animations? The data editor confuses me so much in Sc2, used to having the object editor in WC3. Or is it something I would have to do in a modelling/animation program?
It's one of the data objects under "actor" I believe... I think it's called fidget. You can control how often and what percent of the time a unit will turn or play an animation when idle. You can also make a unit move based on idleness, which is how the critters move around the map. Just set all of these to zero.
It's one of the data objects under "actor" I believe... I think it's called fidget. You can control how often and what percent of the time a unit will turn or play an animation when idle. You can also make a unit move based on idleness, which is how the critters move around the map. Just set all of these to zero.
Yepp that seemed to work, the fidget thing wasn't under actors though ;P Thanks a ton for the help dude, and thanks to everyone else who tried to help :)
Think it's safe to say that this whole thread is solved.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey guys, I'm wondering if it's possible to make a system that drains "fuel" (energy) from a unit based on how far the unit has travelled. So let's say that the unit has traveled 10 yards or whatever measuring unit we're using, then the energy will be drained by 1 per yard. Ofcourse the fuel should be able to be refilled, otherwise the vehicle stops, but I'm pretty sure I can work that part out myself. I'm using this in a TPS engine, I've already made it possible to enter/exit vehicles fluidly and to control them smoothly, thought the fuel system would be a great asset to the vehicle part of the map. Since I'm using it in a TPS engine, I have BossBars to display the energy/fuel (which don't match the actual energy of the unit but that doesn't matter) so it doesn't have to drain energy but rather just set decrease the bar with 1 every time the unit travels say 1 yard or whatever. Thanks in advance, any help or advice greatly appreciated!
@DeepCover187: Go
I KNOW I have seen another topic asking about this same thing, I just can't seem to find it. I think your answer lies in data though, through validating if the unit speed is >0, and if so, allowing a behavior to trigger that decreases energy periodically. I know that may not be the complete answer you were looking for, but try searching the forums - I know I've seen this topic before.
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
If you want to go for a trigger approach, here are a few ideas for you:
- Have a periodic trigger
- Have a point-Variable
- At first, compare the current position with the position saved in the point var
- Calculate distance --> Fuel cost
- Always save the position of the unit into the point var AFTER comparing the distance
- Repeat
Make sure to have at least a 0.5 second interval, since for sure its possible for the unit to travel back to its origin, what would lower the distance. You can avoid this with a check interval <= 0.5 seconds. The smaller the interval, the more accurate this will get.
@DeepCover187:
I would drain energy every X seconds when i moves and disable movement when there is not enough energy.
But that's just me.
Managed to fix it using triggers :D Is there any way to make the unit "Freeze" with triggers? Since now, even if the unit can't move when the fuel is run out, the unit still plays his Stand animations and such.
Set unit movement speed to 0.
Will that really stop him from playing stand animations? And it's not doable with triggers is it?
@DeepCover187: Go
Why don't you just disable stand animations altogether? If your unit is using fuel, and figet animations don't use fuel anyway, why even have them?
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
Well it would be nice to have them there when the vehicle has cargo and stands still, sorry but how do I remove specific animations? The data editor confuses me so much in Sc2, used to having the object editor in WC3. Or is it something I would have to do in a modelling/animation program?
@DeepCover187: Go
It's one of the data objects under "actor" I believe... I think it's called fidget. You can control how often and what percent of the time a unit will turn or play an animation when idle. You can also make a unit move based on idleness, which is how the critters move around the map. Just set all of these to zero.
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
Yepp that seemed to work, the fidget thing wasn't under actors though ;P Thanks a ton for the help dude, and thanks to everyone else who tried to help :) Think it's safe to say that this whole thread is solved.