Exemple #1
0
 void Update()
 {
     if (SyncWithUnityUpdate)
     {
         NativePhysics.WorldUpdate(UseUnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
     }
 }
Exemple #2
0
        public void PolygonSetVertices(int handle, IEnumerable <Vector2> vertices)
        {
            ThrowExceptionIfNativeWorldDoesNotExist();

            // Pack the vertices as an array of NativeVector2s.
            var transportVertices = vertices
                                    .Select(vertex => new TransportVector2(vertex))
                                    .ToArray();

            NativePhysics.PolygonSetVertices(handle, transportVertices, transportVertices.Length);
        }
Exemple #3
0
        public int PolygonCreate(IEnumerable <Vector2> vertices, Vector2 position, float rotation = 0f, float mass = 1f, bool useGravity = false, bool isStatic = false)
        {
            ThrowExceptionIfNativeWorldDoesNotExist();

            // Pack the collection of Vector2s for transport (this also copies the array).
            var transportVertices = vertices
                                    .Select(vertex => new TransportVector2(vertex))
                                    .ToArray();

            return(NativePhysics.PolygonCreate(transportVertices, transportVertices.Length, new TransportVector2(position), rotation, mass, useGravity, isStatic));
        }
Exemple #4
0
 public void PolygonDestroy(int handle)
 {
     NativePhysics.PolygonDestroy(handle);
 }
Exemple #5
0
 void OnDestroy()
 {
     NativePhysics.WorldDestroy();
     DoesNativeWorldExist = false;
 }
Exemple #6
0
 void Awake()
 {
     NativePhysics.WorldStart(FixedTimestepSeconds, GravityAcceleration);
     DoesNativeWorldExist = true;
 }
Exemple #7
0
 public void PolygonAccelerateRotation(int handle, float dRotationalVelocity)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     NativePhysics.PolygonAccelerateRotation(handle, dRotationalVelocity);
 }
Exemple #8
0
 public Vector2 PolygonGetVelocity(int handle)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     return(NativePhysics.PolygonGetVelocity(handle).ToVector2());
 }
Exemple #9
0
 public float PolygonGetRotationalVelocity(int handle)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     return(NativePhysics.PolygonGetRotationalVelocity(handle));
 }
Exemple #10
0
 public void PolygonSetRotationalVelocity(int handle, float rotationalVelocity)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     NativePhysics.PolygonSetRotationalVelocity(handle, rotationalVelocity);
 }
Exemple #11
0
 public void PolygonRotate(int handle, float dRotation)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     NativePhysics.PolygonRotate(handle, dRotation);
 }
Exemple #12
0
 public void PolygonAccelerate(int handle, Vector2 dVelocity)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     NativePhysics.PolygonAccelerate(handle, new TransportVector2(dVelocity));
 }
Exemple #13
0
 public void PolygonSetVelocity(int handle, Vector2 velocity)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     NativePhysics.PolygonSetVelocity(handle, new TransportVector2(velocity));
 }
Exemple #14
0
 public float PolygonGetMass(int handle)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     return(NativePhysics.PolygonGetMass(handle));
 }
Exemple #15
0
 public bool IsPolygonColliding(int handle)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     return(NativePhysics.IsPolygonColliding(handle));
 }
Exemple #16
0
 public void PolygonSetMass(int handle, float mass)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     NativePhysics.PolygonSetMass(handle, mass);
 }
Exemple #17
0
 public void PolygonTranslate(int handle, Vector2 dPosition)
 {
     ThrowExceptionIfNativeWorldDoesNotExist();
     NativePhysics.PolygonTranslate(handle, new TransportVector2(dPosition));
 }