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
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.
New to the forum? Say hello in this topic! Also make sure to read the rules.
Add IPlayer.CrosshairCenter property
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
-
- Superfighter
- Posts: 97
- Joined: Thu Feb 07, 2019 4:36 am
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
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.
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.
0 x
-
- Superfighter
- Posts: 97
- Joined: Thu Feb 07, 2019 4:36 am
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
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
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
-
- Superfighter
- Posts: 97
- Joined: Thu Feb 07, 2019 4:36 am
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
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.
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
- Gurt
- Lead Programmer
- Posts: 1884
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 34
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.
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