Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Add IPlayer.CrosshairCenter property

Here you can find ScriptAPI suggestions implemented in the game.
Forum rules
By using the forum you agree to the following rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Add IPlayer.CrosshairCenter property

Post by NearHuscarl » Fri Mar 13, 2020 3:58 pm

I want to know the center position where the crosshair rotates around while the player is aiming. Currently it seems like the crosshair center is not fixed and tracking it manually is tiresome.

https://i.imgur.com/ZP3AQeD.mp4
0 x
Image

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 24

Post by JakSparro98 » Mon Mar 16, 2020 7:04 pm

Sometimes all you really need is to think out of the box; with the help of the AimVector property, raycast and a little of patience for finding the center you can get the exact position of the crosshair even when it is "colliding" with obstacles

In the video I can see you chose a wrong pivot center for the debug lines, that's why the crosshair seems not to respect a perfect rotational movement.

Image
0 x

NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Post by NearHuscarl » Mon Mar 16, 2020 8:10 pm

JakSparro98 wrote:
Mon Mar 16, 2020 7:04 pm
a little of patience
So you are telling me spending at least an hour to make sure I didn't make a stupid mistake before I posted here is not enough? Also your solution is dead wrong, the center is moving all the time. It's not exactly at any positions. And btw, regardless of you solve it, using raycast in this case is overkill and I would rather like a simple getter for that.
0 x
Image

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 24

Post by JakSparro98 » Tue Mar 17, 2020 1:24 am

I will be straight to the point, adding a getter for something it is purely visual and client side only won't never happen at this stage of the game, in 70% of the cases the script will run server-side and I assume the crosshair is never registered anywhere in net packets, in this case only the rotation of the player in aim state is shared and you will be always able to obtain at least a result similar to what @ebomb09 managed to do in his Baseball Gun script.
0 x

NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Post by NearHuscarl » Tue Mar 17, 2020 6:56 am

JakSparro98 wrote:
Tue Mar 17, 2020 1:24 am
adding a getter for something it is purely visual
It's not just purely visual in Map Editor where I always have 1 ping. I need it to know if my crosshair center is at the right position.
The crosshair is where all projectiles will pass if the spread is none
JakSparro98 wrote:
Tue Mar 17, 2020 1:24 am
in 70% of the cases the script will run server-side
Off Topic
And why is that's so important? SFD online is completely unplayable in my region, and I am sure it's not only me. One of the best features that they added recently is you can now pause the game in offline mode. And if it's not for the offline mode, it will be a hard negative review on steam for me.
JakSparro98 wrote:
Tue Mar 17, 2020 1:24 am
to what @ebomb09 managed
It's not an option to me. That solution requires you to fire a shot to get the direction from IProjectile.Direction. Mine use custom projectile (it's a gravity gun like in half life).

Anyway, I solved the problem somewhat.
Here is the result
Here is the code
The crosshair position is a bit different for every weapons. But at this point, I don't think anyone cares anymore.
0 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 32

Post by Gurt » Sun Mar 22, 2020 8:16 pm

After v.1.3.4 :
ScriptAPI: Added bool IPlayer.GetWeaponMuzzleInfo(out Vector2 worldPosition, out Vector2 direction) so you can read the position of the weapon muzzle of the currently equipped and drawn weapon from a player. You will have to raycast for any clipping if you're in tight spaces.
1 x
Gurt

Locked