Photon Bolt Engine API  1.2.0.3
Properties | Private Member Functions | Static Private Member Functions | List of all members
BoltHitbox Class Reference

Defines one hitbox on a BoltHitboxBody More...

Inheritance diagram for BoltHitbox:

Properties

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

Private Member Functions

void OnDrawGizmos ()
 
bool OverlapSphereOnBox (Vector3 center, float radius)
 
bool OverlapSphereOnSphere (Vector3 center, float radius)
 
bool RaycastSphere (Vector3 o, Vector3 d, out float distance)
 

Static Private Member Functions

static void ClampVector (ref Vector3 value, ref Vector3 min, ref Vector3 max, out Vector3 result)
 

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;
}

Member Function Documentation

◆ ClampVector()

static void BoltHitbox.ClampVector ( ref Vector3  value,
ref Vector3  min,
ref Vector3  max,
out Vector3  result 
)
inlinestaticprivate

◆ OnDrawGizmos()

void BoltHitbox.OnDrawGizmos ( )
inlineprivate

◆ OverlapSphereOnBox()

bool BoltHitbox.OverlapSphereOnBox ( Vector3  center,
float  radius 
)
inlineprivate

◆ OverlapSphereOnSphere()

bool BoltHitbox.OverlapSphereOnSphere ( Vector3  center,
float  radius 
)
inlineprivate

◆ RaycastSphere()

bool BoltHitbox.RaycastSphere ( Vector3  o,
Vector3  d,
out float  distance 
)
inlineprivate

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;
}
}