• Login
sketchucation logo sketchucation
  • Login
โ„น๏ธ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Sketchyphysics health variable

Scheduled Pinned Locked Moved SketchyPhysics
10 Posts 2 Posters 1.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    Rider
    last edited by 17 Apr 2012, 07:50

    i am new to sp and i want to know the method\script to make a health variable(like in real games)
    for a 1st person shooter which gets reduced only when an emitter object(bullet most probably) touches the shooter.
    PLEASE HELP ME!!!

    1 Reply Last reply Reply Quote 0
    • A Offline
      ashscott
      last edited by 25 Apr 2012, 05:49

      Thats going to have something to with the ontouch field.....

      Just some stuff I do with Sketchup.

      1 Reply Last reply Reply Quote 0
      • R Offline
        Rider
        last edited by 26 Apr 2012, 05:56

        but what??
        please tell me if you know .

        1 Reply Last reply Reply Quote 0
        • A Offline
          ashscott
          last edited by 26 Apr 2012, 07:29

          I dont have a lot of experience with ontouch sorry - check this: http://sketchyphysics.wikia.com/wiki/OnTouch

          You're going to have to place a code in the scripted field of your base that says something like

          if frame>1
          setVar("health",5)
          end
          getVar("health")
          if "health" <0
          "self destruct" # or something you want to happen once the health has run out
          

          then in the ontouch field of your object, something like

          ontouch setVar("health",+=-1)
          

          None of that will actually work as the script isn't written right (I don't know all those commands well enough) but it gives you some idea about how to start going about it

          Just some stuff I do with Sketchup.

          1 Reply Last reply Reply Quote 0
          • R Offline
            Rider
            last edited by 29 Apr 2012, 07:12

            That worked but this worked better:
            in the onTick box of the player
            "if
            frame<1
            then
            setVar("Health",2)
            end
            getVar("Health")
            if
            getVar("Health")==2
            then
            Sketchup.active_model.entities[0].text="Health=2"
            end
            if
            getVar("Health")==1
            then
            Sketchup.active_model.entities[0].text="Health=1"
            end
            if
            getVar("Health")==0
            then
            Sketchup.active_model.entities[0].text="Mission Failed!"
            end"
            And in the scripted box of the player
            "ontouch{|toucher|setVar("Health",getVar("Health")-1)}"
            the health gets reduced when anything touches the player.
            And this is my problem !
            i want it to be reduced only when an object named "bullet" touches it.
            please tell me if you know how to sort it out

            1 Reply Last reply Reply Quote 0
            • A Offline
              ashscott
              last edited by 30 Apr 2012, 05:20

              I honestly don't know about getting the ontouch function to only be recorded with the object 'Bullet' but I am sure there is a way of doing it - who else can shed some light?

              Just some stuff I do with Sketchup.

              1 Reply Last reply Reply Quote 0
              • R Offline
                Rider
                last edited by 30 Apr 2012, 06:41

                maybe Wacov or Mr. K. or CPhillips can help us.
                Atlast ,they are sketchyphysics masters .
                Please ask them if you can and tell me quick.

                1 Reply Last reply Reply Quote 0
                • A Offline
                  ashscott
                  last edited by 30 Apr 2012, 06:50

                  You are just as capable as asking them as I am - send them a private message ๐Ÿ˜„

                  Just some stuff I do with Sketchup.

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    Rider
                    last edited by 30 Apr 2012, 07:24

                    i have sent them the PM but i dont think they have recieved it as the messages are in my outbox and not in the sent messages box.
                    You too please send them a PM as i really in need to sort this problem out.
                    PLEASE

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      Rider
                      last edited by 30 Apr 2012, 15:47

                      i have done it!
                      i have found the solution!!
                      this is just what i wanted
                      this is the file.
                      touch the red ball(the player) with anything(black ball) but the green ball(thats the bullet).The health is not reduced!
                      Then touch the + sign with the black ball .No change!
                      Then try the green ball. Touch the red ball with it .The health is reduced!!
                      When low at health touch the + sign with the green ball to restore health !!
                      I am so happy.
                      Thanks for all help Ash! ๐Ÿ˜„ ๐Ÿ˜‰


                      Health.skp

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement