My character is sitting in a car and he is able to move to each seat of the car and turn on a light at each seat. So I have had to use OnComponentOverlaps to check that the player is in a specific seat in order to turn off and on a light.
I would also very much like to find a way to slowly recover battery power when lights are turned off (recovering the power faster the more lights turned off)
Assuming the battery has 100 capacity, charges 10/s and each seat drains 5/s, you should be stable with 2 seat lights on. Completely untested but should work:
This might be enough for something super straightforward. Obviously, there will be as many ways to script this as there are people. If the vehicle has multiple power hungry devices, all drawing power, you’ll need a much more modular approach. Especially when there is more than 1 vehicle… You don’t want to script the above for all 25 different cars in the game.
Thanks! What did you set the numbers for current battery, battery and max battery? Just to give me an idea and I’ll adjust as needed. I’m mainly confused what to put for current battery
Btw, tested the script and it works. I mean, the overall logic will always be the same - we accumulate the drain from all possible sources and then subtract from the charge left in the battery providing there’s enough juice left, ofc.
How should I change this? The Max battery charge variable, if I set it to Battery (which is set to 0) the lights won’t turn on, if I set max battery charge (100) the lights turn on but the battery does not drain
I can’t help if I can’t see what you’ve scripted… What I sent is very generic, you need to work it into the existing system you have (if it’s more complex) or replace it entirely.