TrueSync: TSCollision.cs Source File

TrueSync

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