Hello, I'm making a little script in ACS that draws a scope on the player's screen using hudmessage and camera textures.
However, I'm having troubles making a check if the player is crouching to fix the camera.
The way it's set up right now, is that when the map starts, a camera is spawned and then continuously being placed 8 units in front of the player on the height of 36 units.
However I want to make the height change to 18 units when the player crouches, so the scope remains accurate.
From what I've heard GetActorViewHeight does what I want, but I wasn't able to make it work at all.
An explanation as to how this function works would be highly appreciated.
GetActorViewHeight help?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: GetActorViewHeight help?
While player crouching his height is halved, so Player.ViewHeight value (player's camera height) decreases by the same value too. For ex.:
By default
Height = 56
Player.ViewHeight = 41
so when playerpawn crouches its properties change as
Height = 56/2=28
Player.ViewHeight = 41-28=13
If you want to check that player crouches, then try to check APROP_ViewHeight:
If(CheckActorProperty(0,APROP_ViewHeight,<ViewHeight_while_crouch>)) //<ViewHeight_while_crouch> = 13 for default playerpawn
{
//do something
}
For GetActorViewHeight logic would be the same I guess:
If(GetActorViewHeight(0)<=<ViewHeight_while_crouch>) //<ViewHeight_while_crouch> = 13 for default playerpawn
{
//do something
}
By default
Height = 56
Player.ViewHeight = 41
so when playerpawn crouches its properties change as
Height = 56/2=28
Player.ViewHeight = 41-28=13
If you want to check that player crouches, then try to check APROP_ViewHeight:
If(CheckActorProperty(0,APROP_ViewHeight,<ViewHeight_while_crouch>)) //<ViewHeight_while_crouch> = 13 for default playerpawn
{
//do something
}
For GetActorViewHeight logic would be the same I guess:
If(GetActorViewHeight(0)<=<ViewHeight_while_crouch>) //<ViewHeight_while_crouch> = 13 for default playerpawn
{
//do something
}
Re: GetActorViewHeight help?
Thank you for replying, but neither of the methods work.
At this point, I'm fairly certain that I'm doing something wrong with the script.
I haven't changed anything with playerpawn so default values still apply. (56 height, 41 viewheight)
Yet I can't make this work at all.
Thank you for the effort anyhow, I appreciate it.
At this point, I'm fairly certain that I'm doing something wrong with the script.
Spoiler:I don't know what's wrong with this, it always does what "Else" says and ignores the check completely.
I haven't changed anything with playerpawn so default values still apply. (56 height, 41 viewheight)
Yet I can't make this work at all.
Thank you for the effort anyhow, I appreciate it.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: GetActorViewHeight help?
Oh, sorry. It doesn't work because I've forgot to shift fixed value into int. That Curse strikes me again and again.
Now it should work:
If(GetActorViewHeight(0)>>16<41) //Get player's ViewHeight, shift it into int and as soon as it less than default ViewHeight (41), do something

If(GetActorViewHeight(0)>>16<41) //Get player's ViewHeight, shift it into int and as soon as it less than default ViewHeight (41), do something
Re: GetActorViewHeight help?
Now it works, thank you very much!
Now I wonder if there's a way to interpolate the height change for the camera too....
I'll try to figure something out myself, thank you once again.
Edit: I've got another issue now.
I've been testing it out mostly on MAP01 of Doom 2 and I haven't checked other maps.
But the camera thing isn't placed at player's location in any other map that isn't MAP01.
It's placed somewhere out of bounds as the camera texture is just a black square. (the texture itself is just a white square)
I'll post the script below:
Also I don't know if I should make another post or just edit this one.
I fear I might bump the thread too much, but at the same time I also fear that if I edit this post, people won't check it.
Now I wonder if there's a way to interpolate the height change for the camera too....
I'll try to figure something out myself, thank you once again.
Edit: I've got another issue now.
I've been testing it out mostly on MAP01 of Doom 2 and I haven't checked other maps.
But the camera thing isn't placed at player's location in any other map that isn't MAP01.
It's placed somewhere out of bounds as the camera texture is just a black square. (the texture itself is just a white square)
I'll post the script below:
Spoiler:I don't know what's wrong with it, so if anyone knows I'd appreciate it.
Also I don't know if I should make another post or just edit this one.
I fear I might bump the thread too much, but at the same time I also fear that if I edit this post, people won't check it.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: GetActorViewHeight help?
Well, dunno what are you want to do, but I think that using Warp instead of SetActorPosition will be better option for smooth movement interpolation, smt. like:and make sure that your camera thing will be _IS<POINTER> of player:
TNT1 A 0 A_SpawnItemEx("your_cam_thing",0,0,Height,0,0,0,0,SXF_NOCHECKPOSITION|SXF_ISTRACER,0,500) //You can bear it through maps endlessly "within" player's _Overlay for ex.
Code: Select all
Script "ScopePos" ENTER
{
ChangeCamera(500, 0, FALSE);
If(GetActorViewHeight(0)>>16<41)
{
Warp(AAPTR_TRACER,0+cos(GetActorAngle(0)>>8)*8,0+sin(GetActorAngle(0)>>8)*8,GetActorZ(0)-GetActorFloorZ(0)+18.0,0,WARPF_NOCHECKPOSITION/*|WARPF_ABSOLUTEOFFSET*/|WARPF_INTERPOLATE|WARPF_USEPTR|WARPF_MOVEPTR|WARPF_COPYPITCH);
}
Else
{
Warp(AAPTR_TRACER,0+cos(GetActorAngle(0)>>8)*8,0+sin(GetActorAngle(0)>>8)*8,GetActorZ(0)-GetActorFloorZ(0)+36.0,0,WARPF_NOCHECKPOSITION/*|WARPF_ABSOLUTEOFFSET*/|WARPF_INTERPOLATE|WARPF_USEPTR|WARPF_MOVEPTR|WARPF_COPYPITCH);
}
Delay(1);
Restart;
}
TNT1 A 0 A_SpawnItemEx("your_cam_thing",0,0,Height,0,0,0,0,SXF_NOCHECKPOSITION|SXF_ISTRACER,0,500) //You can bear it through maps endlessly "within" player's _Overlay for ex.
Re: GetActorViewHeight help?
Thank you very much, it works now.
For some reason Spawn function doesn't work on any other map aside MAP01.
So I just used the A_SpawnItemEx you did and put it on CustomInventory, which then I gave to the player via an ENTER script.
And comparing SetActorPosition to Warp, Warp doesn't suffer from some problems I had with SetActorPosition.
Like it lagging behind at times and obscuring the camera with player sprites. (Warp still has some problems with player sprites, but not as much)
Thank you for the help once again.
For some reason Spawn function doesn't work on any other map aside MAP01.
So I just used the A_SpawnItemEx you did and put it on CustomInventory, which then I gave to the player via an ENTER script.
And comparing SetActorPosition to Warp, Warp doesn't suffer from some problems I had with SetActorPosition.
Like it lagging behind at times and obscuring the camera with player sprites. (Warp still has some problems with player sprites, but not as much)
Thank you for the help once again.