TrueSync
TSCollision.cs
1 using UnityEngine;
2 
3 namespace TrueSync {
4 
8  public class TSContactPoint {
9 
13  public TSVector point;
14 
18  public TSVector normal;
19 
20  }
21 
25  public class TSCollision {
26 
30  public TSContactPoint[] contacts = new TSContactPoint[1];
31 
36 
40  public GameObject gameObject;
41 
46 
51 
56 
57  internal void Update(GameObject otherGO, Contact c) {
58  if (this.gameObject == null) {
59  this.gameObject = otherGO;
60  this.collider = this.gameObject.GetComponent<TSCollider>();
61  this.rigidbody = this.gameObject.GetComponent<TSRigidBody>();
62  this.transform = this.collider.tsTransform;
63  }
64 
65  if (c != null) {
66  if (contacts[0] == null) {
67  contacts[0] = new TSContactPoint();
68  }
69 
70  this.relativeVelocity = c.CalculateRelativeVelocity();
71 
72  contacts[0].normal = c.Normal;
73  contacts[0].point = c.p1;
74  }
75  }
76 
77  }
78 
79 }
TSRigidBody rigidbody
TSRigidBody of the body hit, if there is one attached
Definition: TSCollision.cs:45
TSVector point
Contact point between two bodies.
Definition: TSCollision.cs:13
TSVector normal
Normal vector from the contact point.
Definition: TSCollision.cs:18
Represents a physical 3D rigid body.
Definition: TSRigidBody.cs:11
A deterministic version of Unity&#39;s Transform component for 3D physics.
Definition: TSTransform.cs:9
A vector structure.
Definition: TSVector.cs:29
TSCollider collider
TSCollider of the body hit
Definition: TSCollision.cs:35
Abstract collider for 3D shapes.
Definition: TSCollider.cs:12
TSTransform transform
TSTransform of the body hit
Definition: TSCollision.cs:50
GameObject gameObject
GameObject of the body hit.
Definition: TSCollision.cs:40
Represents information about a contact point.
Definition: TSCollision.cs:8
TSVector relativeVelocity
The TSTransform of the body hit.
Definition: TSCollision.cs:55
Represents information about a contact between two 3D bodies.
Definition: TSCollision.cs:25