Ive got a powerup i need it to last 15 seconds
by Mark Junior · in Torque Game Engine · 12/11/2006 (7:53 am) · 10 replies
EDIT: EDIT: READ: !!!!: Hi, ive got a powerup in my fps game. but I want it so that when you get the powerup it will last only a amount of time till it wares off. Does anyone know how to do this?
About the author
#2
12/11/2006 (9:39 am)
Thanks
#3
function Player::toggleGodMode(%this)
{
if (Player.godMode)
Player.godMode = false;
else
Player.godMode = true;
}
i modified it to be like this:
function Player::toggleGodMode(%this)
{
if (Player.godMode)
Player.godMode = false;
else
Player.godMode = true;
echo("IT WORKS");
}
but it didnt say it works in the console when i picked the powerup up
12/11/2006 (10:17 am)
Onfunction Player::toggleGodMode(%this)
{
if (Player.godMode)
Player.godMode = false;
else
Player.godMode = true;
}
i modified it to be like this:
function Player::toggleGodMode(%this)
{
if (Player.godMode)
Player.godMode = false;
else
Player.godMode = true;
echo("IT WORKS");
}
but it didnt say it works in the console when i picked the powerup up
#4
12/11/2006 (10:18 am)
I cant tell if it lasts for 15 seconds or not :P cause my powerup is speed so i cant really tell if its gone in 15 seconds
#5
just wondering, shouldnt it be:
function Player::toggleGodMode(%this)
{
if (%this.godMode)
%this.godMode = false;
else
%this.godMode = true;
}
12/11/2006 (11:03 am)
Use a centerprint or some kind of message on screen to test it... pop up a gui or use a sound effect anything will work.just wondering, shouldnt it be:
function Player::toggleGodMode(%this)
{
if (%this.godMode)
%this.godMode = false;
else
%this.godMode = true;
}
#6
12/11/2006 (11:07 am)
I'm not sure if Item has an onPickup callback or not, how were you registering the powerup being activated before?
#7
Your right, I didnt even notice that.
I think you could call your 'toggleGodMode' in Item::onRemove or maybe in onCollision (assuming item has that also... )
12/11/2006 (12:08 pm)
@jamesYour right, I didnt even notice that.
I think you could call your 'toggleGodMode' in Item::onRemove or maybe in onCollision (assuming item has that also... )
#8
12/12/2006 (4:36 am)
I used TorqueLogoItem::OnCollision... not OnPickup though i didnt add this in any function
#9
12/12/2006 (4:37 am)
I just created another function onpickup after the oncollision function
#10
12/12/2006 (5:52 am)
Speed will not work if you are modifying the runSpeed variables.
Torque Owner James Terry
i.e
function Player::toggleGodMode(%this) { if (Player.godMode) Player.godMode = false; else Player.godMode = true; }in the onPickup or whatever trigger is called when you get the powerup you set Player.godMode = true
function Powerup::onPickup(%this) { Player.toggleGodMode(); Player.schedule(15000, "toggleGodMode"); }of course you want checks to make sure godmode isn't active when you pickup the powerup and adjust accordingly