SetNet.Hitscan 1.2.0

dotnet add package SetNet.Hitscan --version 1.2.0
                    
NuGet\Install-Package SetNet.Hitscan -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SetNet.Hitscan" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SetNet.Hitscan" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SetNet.Hitscan" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SetNet.Hitscan --version 1.2.0
                    
#r "nuget: SetNet.Hitscan, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SetNet.Hitscan@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SetNet.Hitscan&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SetNet.Hitscan&version=1.2.0
                    
Install as a Cake Tool

SetNet.Hitscan

Server-authoritative instant-hit (hitscan) shooting for SetNet — with a fully pluggable hit test.

The whole point is the IHitDetector interface: you decide what a shot hits. Bring your own collision, or compose the shipped detectors.

using SetNet.Hitscan;

// ── bring your own hit test ──────────────────────────────
public sealed class MyDetector : IHitDetector
{
    public HitResult Raycast(in Ray ray, in HitQuery query)
    {
        // cast against YOUR world / entities however you like; return the closest hit or HitResult.Miss
        if (MyPhysics.Raycast(ray.Origin, ray.Direction, query.MaxDistance, out var hit, out var id))
            return new HitResult(HitKind.Target, hit.Point, hit.Distance, hit.Normal, id, hit.Entity);
        return HitResult.Miss;
    }
}

var gun = new HitscanResolver(new MyDetector());
gun.OnHit += r => Damage(r.TargetId!, weapon.Damage);
var result = gun.Fire(muzzle, aimDir, shooterId: "player", maxDistance: 80);

Or use the shipped detectors

// sphere targets (your entities) + world geometry, closest wins (a wall blocks a target behind it)
var detector = new CompositeHitDetector(
    new TargetHitDetector(myTargetProvider),      // ITargetProvider → HitTarget spheres
    new GeoDataHitDetector(geo));                 // SetNet.GeoData world raycast

var gun = new HitscanResolver(detector);
  • IHitDetector.Raycast(in Ray, in HitQuery)HitResult — the seam you implement (or reuse). Returns the closest hit within HitQuery.MaxDistance, or HitResult.Miss.
  • ITargetProvider supplies HitTarget spheres (id + centre + radius + your payload) for the query; TargetHitDetector does the ray-vs-sphere.
  • GeoDataHitDetector wraps IGeoData.Raycast for walls/cover.
  • CompositeHitDetector merges detectors, returning the nearest.
  • HitscanResolver adds ignore-self, default range, OnShot/OnHit events; Fire(origin, dir, shooterId, maxDistance?, faction?, context?)HitResult.

HitResult: Hit, Kind (Target/World), Point, Distance, Normal, TargetId, Target (your entity). The same IHitDetector also drives SetNet.Projectiles, so your collision code is reused for both.

Depends on SetNet.GeoData (for Vec3 + IGeoData). No wire — the app broadcasts the result its own way. License: MIT.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SetNet.Hitscan:

Package Downloads
SetNet.Projectiles

Server-authoritative travelling projectiles for SetNet: spawn with a velocity, advance each tick (optional gravity), and sweep-test the path with the SAME pluggable IHitDetector as SetNet.Hitscan — so you bring your own hit detection. Lifetime/range, Hit/Expired events, on-hit callback. Auto-subscribes to SetNet.Ticks (or drive Update(dt) yourself). Depends on SetNet.Hitscan + SetNet.GeoData + SetNet.Ticks.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 124 8/5/2026