Sketchyphysics health variable
-
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!!! -
Thats going to have something to with the ontouch field.....
-
but what??
please tell me if you know . -
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
-
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 -
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?
-
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. -
You are just as capable as asking them as I am - send them a private message
-
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 -
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!
Advertisement