Photon Bolt Engine API
Networking Middleware
Properties | List of all members
BoltHitbox Class Reference

Defines one hitbox on a BoltHitboxBody More...

Inheritance diagram for BoltHitbox:

Properties

BoltHitboxShape hitboxShape [get, set]
 Shape of the hitbox (box or sphere) More...
 
BoltHitboxType hitboxType [get, set]
 Type of the hitbox More...
 
Vector3 hitboxCenter [get, set]
 Center of the hitbox in local coordinates More...
 
Vector3 hitboxBoxSize [get, set]
 Size of the hitbox if this shape is a box More...
 
float hitboxSphereRadius [get, set]
 Type of the hitbox More...
 

Detailed Description

Defines one hitbox on a BoltHitboxBody

Example: Resizing a sphere hitbox

void ResizeSphereHitbox(BoltHitbox hitbox, float newRadius) {
if(hitbox.hitboxShape != BoltHitboxShape.Sphere) {
Debug.Log("Attemping to resize a non-sphere hitbox");
return;
}
hitbox.hitboxSphereRadius = newRadius;
}

Property Documentation

◆ hitboxBoxSize

Vector3 BoltHitbox.hitboxBoxSize
getset

Size of the hitbox if this shape is a box

Example: A method to double the size of a player's head hitbox if it is a box.

void DoubleHeadSize(BoltHitboxBody body) {
foreach(BoltHitbox hitbox in body.hitboxes) {
if(hitbox.hitboxType == BoltHitboxType.Head) {
hitbox.hitboxBoxSize = hitbox.hitboxBoxSize * 2f;
}
}
}

◆ hitboxCenter

Vector3 BoltHitbox.hitboxCenter
getset

Center of the hitbox in local coordinates

Example: Getting a vector that points from the player's weapon to the head of a target entity.

Vector3 GetHeadshotVector(BoltEntity target, IWeapon currentWeapon) {
BoltHitboxBody body = target.GetComponent<BoltHitboxBody%gt();
BoltHitbox head = body.hitboxes[0];
foreach(BoltHitbox hitbox in body.hitboxes) {
if(hitbox.hitboxType == BoltHitboxType.Head) {
head = hitbox;
}
}
return head.hitboxCenter - currentWeapon.fireOrigin;
}

◆ hitboxShape

BoltHitboxShape BoltHitbox.hitboxShape
getset

Shape of the hitbox (box or sphere)

Example: Sorting the hitboxes in a body based on shape.

void ConfigureHitboxes(BoltHitboxBody body) {
foreach(BoltHitbox hitbox in body.hitboxes) {
switch(hitbox.hitboxShape) {
case BoltHitboxShape.Sphere: ConfigureSphere(hitbox); break;
case BoltHitboxShape.Box: ConfigureBox(hitbox); break;
}
}
}

◆ hitboxSphereRadius

float BoltHitbox.hitboxSphereRadius
getset

Type of the hitbox

Example: A method to double the size of a player's head hitbox if it is a sphere.

void DoubleHeadSize(BoltHitboxBody body) {
foreach(BoltHitbox hitbox in body.hitboxes) {
if(hitbox.hitboxType == BoltHitboxType.Head) {
hitbox.hitboxSphereRadius = hitbox.hitboxSphereRadius * 2f;
}
}
}

◆ hitboxType

BoltHitboxType BoltHitbox.hitboxType
getset

Type of the hitbox

Example: Modifying a base damage value depending on the area of the hit.

float CalculateDamage(BoltHitbox hit, float baseDamage) {
switch(hit.hitboxType) {
case BoltHitboxType.Head: return 2.0f * baseDamage;
case BoltHitboxType.Leg:
case BoltHitboxType.UpperArm: return 0.7f * baseDamage;
default: return baseDamage;
}
}