Search In
• More options...
Find results that contain...
Find results in...
• 0

# Is it possible to have player's mouse look limited?

## Question

Basically what I am trying to do is a sequence where the player cannot look up to the ceiling completely, only half the way and the same to down, left and right.

Like the player could not look outside of an invisible grid.

Kind of like this (2:40):

Any help would be appreciated.

Thanks,

One Doomed Bunny

## Recommended Posts

• 1

change the minangle and maxangle values, those were just examples:

int minangle = 0.25; //fixed point angle
int maxangle = 0.75;

• 1

You could probably achieve this by getting setting the player's initial angle using SetActorAngle then forcing him to look only between 2 specific angles using the same function, I did something like that for and old thing I made.

Quote

int minangle = 0.5; //fixed point angle

int maxangle = 1.0;

If(GetActorAngle(0) < minangle)

{

SetActorAngle(0, minangle);

}

else

If(GetActorAngle(0) > maxangle)

{

SetActorAngle(0, maxangle);

}

Not sure about Looking up/down though.

• 1
3 minutes ago, One Doomed Bunny said:

About the looking/up down. is there a way to disable up down temporarily? That could work as well. ﻿

You could use the same approach tempdecal.wad described, just with GetActorPitch and SetActorPitch.

• 1

From the wiki:

Quote

The actor's pitch is a fixed point angle. Due to the limits of freelook in the software renderer, this value is bounded by -0.0888977 (approximately -32°) and 0.155548 (approximately 56°), more precisely -5825 and 10194 as ints, but in GL freelook will go from -0.25 (-90°) to 0.25 (+90°). Note that looking up produces a negative value and looking down produces a positive value. 0 is looking straight ahead.

So you probably need something like

```int minpitch = -0.125; // looking up
int maxpitch = 0.125; // looking down

if(GetActorPitch(1) < minpitch)
SetActorPitch(1, minpitch)
else if(GetActorPitch(1) > maxpitch)
SetActorPitch(1, maxpitch)```

• 1

Should also note that your script is only going to be executed once / 1 frame, so you want to use loops if you want to do it for every frame

```script 2 (void)
{
int minangle = 0.5; //fixed point angle
int maxangle = 1.0;
while(true)
{
If(GetActorAngle(1) < minangle)
{
SetActorAngle(1, minangle);
}
else
If(GetActorAngle(1) > maxangle)
{
SetActorAngle(1, maxangle);
}
int minpitch = -0.125; // looking up
int maxpitch = 0.125; // looking down
if(GetActorPitch(1) < minpitch)
{
SetActorPitch(1, minpitch);
}
else
if(GetActorPitch(1) > maxpitch)
{
SetActorPitch(1, maxpitch);
}
delay(1);
}
}```

• 0

You could probably achieve this by getting setting the player's initial angle using SetActorAngle then forcing him to look only between 2 specific angles using the same function, I did something like that for and old thing I made.

Not sure about Looking up/down though.

Thank you I shall try it out.

About the looking/up down. is there a way to disable up down temporarily? That could work as well.

• 0
4 minutes ago, boris said:

You could use the same approach tempdecal.wad described, just with GetActorPitch and SetActorPitch.

Ah, I see. Thanks, both of ya.

• 0
On 7/27/2019 at 7:16 PM, tempdecal.wad said:

You could probably achieve this by getting setting the player's initial angle using SetActorAngle then forcing him to look only between 2 specific angles using the same function, I did something like that for and old thing I made.

Not sure about Looking up/down though.

On 7/27/2019 at 7:28 PM, boris said:

You could use the same approach tempdecal.wad described, just with GetActorPitch and SetActorPitch.

Hello again!

So, I did this:

Quote

#include "zcommon.acs"

script 1 ENTER
{
Thing_ChangeTID(0, 1 + PlayerNumber()); // This assigns the TID
}

script 2 (void)
{
int minangle = 0.5; //fixed point angle

int maxangle = 1.0;

If(GetActorAngle(1) < minangle)

{

SetActorAngle(1, minangle);

}

else

If(GetActorAngle(1) > maxangle)

{

SetActorAngle(1, maxangle);

}

int minpitch = 0.75; //fixed point pitch

int maxpitch = 0.25;

If(GetActorpitch(1) < minpitch)

{

SetActorpitch(1, minpitch);

}

else

If(GetActorPitch(1) > maxpitch)

{

SetActorpitch(1, maxpitch);

}

}

I thought it was working but apparently it does not. When the player activates the script he just looks up and that is it. I am probably missing something obvious...

Any help would be appriciated!

• 0

Should also note that your script is only going to be executed once / 1 frame, so you want to use loops if you want to do it for every frame

```
script 2 (void)
{
int minangle = 0.5; //fixed point angle
int maxangle = 1.0;
while(true)
{
If(GetActorAngle(1) < minangle)
{
SetActorAngle(1, minangle);
}
else
If(GetActorAngle(1) > maxangle)
{
SetActorAngle(1, maxangle);
}
int minpitch = -0.125; // looking up
int maxpitch = 0.125; // looking down
if(GetActorPitch(1) < minpitch)
{
SetActorPitch(1, minpitch);
}
else
if(GetActorPitch(1) > maxpitch)
{
SetActorPitch(1, maxpitch);
}
delay(1);
}
}﻿```

Okay this script so far has done the trick but there is one small issue. When the player looks left his "point of view" teleports to the right.

• 0

change the minangle and maxangle values, those were just examples:

int minangle = 0.25; //fixed point angle
int maxangle = 0.75;

Ah, right I just noticed that. Thank you so much.