How do I add to variable on collision then subtract if collision is no longer present?

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I have a basic battery testing idea where a positive probe is on the positive terminal and a negative probe is on the negative terminal (drag and drop) adding one each to a global variable which outputs a screen on a meter of "12V" what I need to happen is.... If one of the probes is removed from the terminal how do I alter the global variable (to anything other than 2) so an output screen can show "0V"

    Any help would be appreciated - I'm still very new to Construct 3 but love it!

    Casey

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Did you try overlap? If object is overlapping terminal, set global var to true else set false. If else is tricky to use because you are new, you can use if object is NOT overlapping terminal by inverting the overlap condition (right-click event - invert)

  • Not sure if i understand you correctly but if i do theres alot of ways to alter The variable, for example you can create 3 global variables, 1 called "plus" one called "minus" and The third called "volt".

    Now use a invisible collision box for example a transparent Sprite, do two of them actually call 1 pluscol and 1 minuscol and place them where you want The drag and drop to check for collision. Minus goes where The minus is and plus one goes where plus is.

    Create a instant variable on each collision Sprite, call it col and set it to 0.

    Now you can use The is overlapping or on collision in the event sheet, i would click The minus col Sprite in the event sheet, and set to is overlapping another object (this object is The one you use The cable or whatever) if so then set instant variable to 1, then do another event that checks that instant variable, if col=1 then set plus(global variable) to 1, then do another event

    That checks if system>global variable plus minus is both 1, if they are both 1 write text 12 v. The rest you Will figure out I can help you by showing it if you uoload2your project here, happy newyears

  • Thanks guys! I wound up getting into a lot of circular arguments but after reading through your replies over & over again (Lol!) I finally got it to behave! I'm sure it's far from elegant but for now it's doing what I needed!!

    Many thanks!

  • Very Nice! Reading things over and over is how you learn, i am sorry if my explanation was abit blurry , it was new years eve (= Nice job and keep It going!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)