Game Development Community

Remove crosshair while running

by Karsten "Clocks" Viese · in Torque Game Engine · 09/05/2001 (2:15 am) · 12 replies

In my recent quest to perfect the whole crosshair acpect of my project another question just popped up.

I want to remove the crosshair while running to reduce the aiming capability (of the player), making it harder to hit your target while running since you will not have a crosshair.

I think this could be done in the default.bind.cs

Like adding:

reticleHud.Visible = 0;

to the move function: //this should be copied to the rest of the movement directions, but I know how to do this :)

function moveforward(%val)
{
$mvForwardAction = %val;
}


somehow.

Anyone like to give this a try since I still suffers from "programmers blindness".

The end result should be this:

When you stand still you will have the crosshair but when you move (in any direction) it will disappear. When you stop and stand still again the crosshair reappears.

Anyone?

// Clocks out.

#1
09/05/2001 (2:23 am)
Wow, that was easy :)

But a new problem arose(sp?)

I did this:

function moveforward(%val)
{
$mvForwardAction = %val;
reticleHud.Visible = 0; // make normal crosshair invisible

}


And the crosshair did go away when i moved but....

It did NOT reappear when I stopped like I wanted it to.

Since there isnt any stand still function in the default.bind.cs I simply just can't add:


reticleHud.Visible = 1; // make normal crosshair visible

To it, would have been to easy, I guess.

So anyone knows how to fix this.

// Clocks out.
#2
09/05/2001 (7:02 am)
I haven't checked, but I have a feeling %val is the state of the key being pressed. 1 if pressed 0 if released.

Try this:
function moveforward(%val) 
{ 
    $mvForwardAction = reticleHud.Visible = %val; 
}

That *should* work if I'm right. But it would be easily changed by the client. If you want to force this upon the client, you should only release the dso's.

BTW, does anyone know how secure the dso's actually are? Can people distribute only those and feel as safe as they would if everything was hardcoded?


Dark
#3
09/05/2001 (7:16 am)
yeah I belive that was the purpose for the dso files
Anthony
#4
09/05/2001 (7:42 am)
reply to Chris:

It's close but not all there.

Now it does the whole thing backwards, meaning it displays the crosshair when moving and remove it when standing still.

And I'm still too dumb to figure out how to invert this.

I have tried the change the initial state of the crosshair to "0" making it invisible hoping that would invert the process but that didn't work.

Any ideas anyone?

Thx anyway:)

// Clocks out.
#5
09/05/2001 (8:58 am)
%val = true (1) if the key is being pressed.
%val = false (0) if the key is being released.

Therefore, the func should look like this:

function moveforward(%val)
{
$mvForwardAction = %val;
recticleHud.Visible = !%val;
}

You want the recticle to be invisible when the key is pressed and visible when released, so you need the opposite (!) of %val assigned to the Visible property.
#6
09/05/2001 (9:19 am)
Check the HUD objects Code Snippits
#7
09/05/2001 (9:41 am)
Reply to Justin Mette:

Do I have to add this:

%val = true (1) if the key is being pressed.
%val = false (0) if the key is being released.

anywhere, or were you just making a point?
Cos I did not add anything but this code:

function moveforward(%val)
{
$mvForwardAction = %val;
recticleHud.Visible = !%val;
}


and it didn't work.

I also did try to add the ! to the code I already had like this:

function moveforward(%val)
{
$mvForwardAction = reticleHud.Visible = !%val;
}


And it worked fine regarding the crosshair but now the player model moved when I released the key and stopped when I pressed it :)

Any ideas that I could try out?

Reply to Pat Wilson:

I'm not a programmer and I dont have a compiler so I'm guessing I can't use your HUD objects Code Snippits.

Is this correct?

Thx guys for all you help.

I really need this so if anyone can get it to work to move my project beyond the fragfest/spray and pray gamestyle.

// Clocks out.
#8
09/05/2001 (10:39 am)
The val is how much you are moving forward I think. So the code should be like this:

function moveforward(%val)
{
$mvForwardAction = %val;
if (%val)
{
reticleHud.Visible = 0; // make normal crosshair invisible
}
else
{
reticleHud.Visible = 1;
}

}

If this doesnt work, it is because the function is only called when the player presses the key. So there is no way to disable it from this function, you will have to find another way. SOrry.
#9
09/05/2001 (11:08 am)
Yep, that's the one that did it alright.

Thx Josh.

Although there is still a problem in all this.

If I move forward the crosshair disappear (good) but if I press the "E" to get the scope working while moving and then release the "E" and I'm still moving the crosshair appears (bad), this also happens with the binoculars.

The best way to fix this (in my situation) is to lock the zoom and binoculars function to a standing state.
Meaning that if you press either (zoom and binoculars) the player the player will stop.

How do I do this?

(Maybe I should learn to program soon)

// Clocks out.
#10
09/05/2001 (11:17 am)
Hmmm

The suggestion made by Josh seemed to work fine, but for one little thing. Now the crosshair is ON in the 3rd person view again.

// Clocks out.
#11
09/05/2001 (11:34 am)
add it like this:

$mvForwardAction = %val;
recticleHud.Visible = !%val;

and not like this:

$mvForwardAction = reticleHud.Visible = !%val;


the ! is to reverse it... so what you did with the second thing i show here is invert the forward action too... just write it as the first thing i show and it should work fine
#12
09/05/2001 (11:49 am)
I'm sorry Ward, but that don't work, did you test this yourself.
All that happends is it moves fine but the crosshair don't disappear.

// Clocks out.