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

1 void ResizeSphereHitbox(BoltHitbox hitbox, float newRadius) {
2  if(hitbox.hitboxShape != BoltHitboxShape.Sphere) {
3  Debug.Log("Attemping to resize a non-sphere hitbox");
4  return;
5  }
6 
7  hitbox.hitboxSphereRadius = newRadius;
8 }

Property Documentation

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.

1 void DoubleHeadSize(BoltHitboxBody body) {
2  foreach(BoltHitbox hitbox in body.hitboxes) {
3  if(hitbox.hitboxType == BoltHitboxType.Head) {
4  hitbox.hitboxBoxSize = hitbox.hitboxBoxSize * 2f;
5  }
6  }
7 }
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.

1 Vector3 GetHeadshotVector(BoltEntity target, IWeapon currentWeapon) {
2  BoltHitboxBody body = target.GetComponent<BoltHitboxBody%gt();
3  BoltHitbox head = body.hitboxes[0];
4 
5  foreach(BoltHitbox hitbox in body.hitboxes) {
6  if(hitbox.hitboxType == BoltHitboxType.Head) {
7  head = hitbox;
8  }
9  }
10 
11  return head.hitboxCenter - currentWeapon.fireOrigin;
12 }
BoltHitboxShape BoltHitbox.hitboxShape
getset

Shape of the hitbox (box or sphere)

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

1 void ConfigureHitboxes(BoltHitboxBody body) {
2  foreach(BoltHitbox hitbox in body.hitboxes) {
3  switch(hitbox.hitboxShape) {
4  case BoltHitboxShape.Sphere: ConfigureSphere(hitbox); break;
5  case BoltHitboxShape.Box: ConfigureBox(hitbox); break;
6  }
7  }
8 }
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.

1 void DoubleHeadSize(BoltHitboxBody body) {
2  foreach(BoltHitbox hitbox in body.hitboxes) {
3  if(hitbox.hitboxType == BoltHitboxType.Head) {
4  hitbox.hitboxSphereRadius = hitbox.hitboxSphereRadius * 2f;
5  }
6  }
7 }
BoltHitboxType BoltHitbox.hitboxType
getset

Type of the hitbox

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

1 float CalculateDamage(BoltHitbox hit, float baseDamage) {
2  switch(hit.hitboxType) {
3  case BoltHitboxType.Head: return 2.0f * baseDamage;
4 
5  case BoltHitboxType.Leg:
6  case BoltHitboxType.UpperArm: return 0.7f * baseDamage;
7 
8  default: return baseDamage;
9  }
10 }