So for my game that I am making I need at least 2 states. A "Clickable/select able state, and a tracking state, so a players unit can track to a resource, enemy, etc. In order to do this, I am using states to separate each one. So the code I am using is this :
import GameLogic#sensors SMouseOverAny = "sMouseOverAny" SMouseLeft = "sMouseLeft" ATrackTo = "aTrackTo" #check to make sure it is in fact a "resource" def trackToResource(cont): sMouseOver = cont.sensors[SMouseOverAny] if "resource" not in sMouseOver.hitObject: return #check for sensor activation if not sMouseOver.positive: return sMouseLeft = cont.sensors[SMouseLeft] if not sMouseLeft.positive: return #activate trackto actuator with selected target aTrackTo = cont.actuators[ATrackTo] aTrackTo.target = sMouseOver.hitObject cont.activate(aTrackTo)
So there are 2 immediate problems I face. first of all, when I click on a person to go to an object (by changing states through mouse over and left click sensors connected to a state set actuator) and proceed to click on another “resource” they track to it, which is fine. However if i click on another guy to activate their track to function, or click on a new object, the target is updated (which I don’t exactly understand why, but I believe it has to do with how the game loop functions as I do some more research). I figured I could solve this problem by switching back to the “select able” state, which stops the update, but brings about problem #2. When the character goes back to the first state, the new target doesn’t “lock in” it reverts back to none. So I need to find a way to “lock in” the new target when it reverts back to its selectable state.
Thanks for any help .