Crosshair and player turning

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

Crosshair and player turning

Postby Apeirogon » Mon May 07, 2018 6:14 am

How make crosshair move in some area on screen, if player move mouse, before actualy turn player?

If I badly explained what I want, heres a picture.
HRODA6A4.gif


Crosshair should be inside red circle(maybe not so large) all time, and must move freely inside this circle. Crosshair still constrolled by mouse/joystick "mushroom"/touchpad/etc.
Optionaly, change direction of shoot bullets, so they fly in direction where crosshair aim, but I think I can found workaround for this.

But player must and should turn only if crosshair try to go out of bound of this red circle. Like, if crosshair tries to go beyond the most upper borders of circle - player camera turns up, most left border - turn left, down border - turn down, south-west border - turn in south-west direction, etc.

I remember I see something like this before, but it was made using acs script, and I need zscript version.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Crosshair and player turning

Postby Apeirogon » Fri May 18, 2018 1:11 pm

I found video, but as I said, its on acs.
https://www.youtube.com/watch?v=ZB3Gj7CGjF8
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Crosshair and player turning

Postby Matt » Fri May 18, 2018 5:52 pm

The term I think is "aiming dead zone".

It can be done, but it does mess with player movement prediction so it might not look good in multiplayer.


First, you need to study MovePlayer() and CheckPitch() to figure out what you need to replace.

(basically you need to modify them so they only turn the player after a certain threshold, but still receive input for turning)

Then you need to replace the player pawn to add variables storing the position of the cursor.

Then you need to replace the status bar, and have the crosshair be drawn where the cursor should be. (I don't know how to draw the crosshair; worst case senario you can just draw your own cursor image)
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Crosshair and player turning

Postby Apeirogon » Sat May 19, 2018 2:54 pm

from check pitch

// The player's view pitch is clamped between -32 and +56 degrees,
// which translates to about half a screen height up and (more than)
// one full screen height down from straight ahead when view panning
// is used.


What?

positions of cursor

You mean ui process event? Or input process?

And why I must use status bar, if there are render overlay?
Or just even create dumy actor with crosshair spite, which float around player.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Crosshair and player turning

Postby Matt » Mon May 21, 2018 6:54 pm

Oh, right, you want to do it through an overlay.

I'd really rather not touch those since I have no idea how the various types of offsets interact...
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia


Return to Scripting

Who is online

Users browsing this forum: TweetMeme [Bot] and 2 guests