#Trying to get hitbox of bodypart from player using raycast
1 messages · Page 1 of 1 (latest)
I've tried raycast.Value.collider.gameObject.GetComponent<HitboxIdentity>();
Trying to get hitbox of bodypart from player using raycast
I've did it
just need to raycast for hitbox layermask and not all layermask
[YE] Trying to get hitbox of bodypart from player using raycast
[ANSWERED] Trying to get hitbox of bodypart from player using raycast
I was very wrong it did not work
Trying to get hitbox of bodypart from player using raycast
I'm pretty sure just raycast.Value.collider is the actual hitbox of whatever the collider collided with
Player(clone)
wait I haven't tried logging the collider itself only gameObject
I'll try it
Collider: Player(Clone) (UnityEngine.CharacterController)
This works
This would be a bit of a safer way to do it
Of course you'd want to log before the returns so you get the right info
If you're cool and like Harmony patches
[HarmonyPatch(typeof(HitscanResult), nameof(HitscanResult.RegisterDamage))]
public class LogHitbox : CustomItemBase<LogHitbox>
{
protected internal override string Name => "LogHitbox";
protected internal override Rarity Rarity => Rarity.Custom;
protected internal override string Description => "Debug thing";
protected internal override ItemType ItemType => ItemType.GunCOM18;
protected internal override Color PickupLightColor => Color.white;
public static void Prefix(IDestructible dest, ref float appliedDamage, AttackerDamageHandler handler)
{
if (handler is not FirearmDamageHandler dh ||
dest is not HitboxIdentity identity ||
!CustomItemData.ContainsKey(dh.Firearm.ItemSerial))
return;
Logger.Info(identity.name);
appliedDamage *= 0.5f;
}
}
Something I whipped up
The relevant bit is
[HarmonyPatch(typeof(HitscanResult), nameof(HitscanResult.RegisterDamage))]
public class FirearmStuff
{
private static bool Check(ushort firearmSerial) => true; // If this is true, run the half damage code
public static void Prefix(IDestructible dest, ref float appliedDamage, AttackerDamageHandler handler)
{
if (handler is not FirearmDamageHandler dh ||
dest is not HitboxIdentity identity ||
!Check(firearmSerial))
return;
Logger.Info(identity.name); // The name of the body part you're hitting
appliedDamage *= 0.5f; // Changing the applied damage, not necessary but it's a typical example of what you'd use this kind of thing for
}
}
@ashen kettle I know you said no Harmony patches but they really are a useful tool, and this is something that'd work for your purposes, and would prevent the need to do double raycasts every time a person shoots a weapon (unnecessary server load)
Might actually be a noticeable performance improvement when handling larger gun fights
Raycasts tend to be decently expensive
Yeah
Especially because the game runs on a single thread
I'm not using patches because I just don't know how to do that, no tutorial ever worked and I just kinda gave up on them
They're pretty easy, there's just not a lot of good resources out there
Let me send you the site I look at for docs
Pretty good stuff
Figured, been trying to learn but when all I see is 40 lines of instructions I feel like there's a more obscure reason hid in the game files that I actually understand
Rather than patching I've just publicized my assembly csharp and did everything using that
The hardest bits are transpilers but they're niche and able to be avoided
I had to do both haha
Publicizing is good for avoiding needing reflection
Not necessarily avoiding patching
Anyway
do you know
how the game handles item animations?
Cuz' I've been trying to force one but I can't seem to find anything that actually plays the animation
In order to force an item animation you have to force the item to be used, as animations and things are handled client-side
Cant you send a fake sync to the player just to play the animation?
That only works if animations are handled by network messages, but I don't believe they are
Fake syncing is the server telling the client something that isn't true
The server knows it's one thing, but tells the client another
@mighty yacht could you check your dms?