// Update is called once per frame void Update() { PhysicsNativePlugin.UpdatePhysicsWorld(Time.deltaTime); Vector3 pos = Vector3.zero; pos.x = PhysicsNativePlugin.GetParticlePosX("particle1"); pos.y = PhysicsNativePlugin.GetParticlePosY("particle1"); pos.z = PhysicsNativePlugin.GetParticlePosZ("particle1"); Debug.Log(pos); }
private void FixedUpdate() { // Set the transformation matrices transformMatrix = Matrix4x4.TRS(transform.position, rotation, new Vector3(1, 1, 1)); invTransformMatrix = transformMatrix.inverse; // Change position and rotation to the positional and rotational variables transform.position = position; PhysicsNativePlugin.AddForce(1, 0, 0, element); Vector3 newPos = position; PhysicsNativePlugin.UpdateParticle(ref newPos.x, ref newPos.y, ref newPos.z, Time.fixedDeltaTime, element); position = newPos; }
private void Start() { if (!PhysicsNativePlugin.hasBeenEnabled) { PhysicsNativePlugin.CreatePhysicsWorld(); PhysicsNativePlugin.hasBeenEnabled = true; } // Initialize values Mass = mass; position = transform.position; inertiaTensor = InertiaTensor.GetInertiaTensor(this, shape, isHollow); rotation = transform.rotation; element = PhysicsNativePlugin.AddParticle(mass, position.x, position.y, position.z); }
// Start is called before the first frame update void Start() { PhysicsNativePlugin.CreatePhysicsWorld(); PhysicsNativePlugin.AddParticle("particle1", 0.5f); PhysicsNativePlugin.AddForceXToParticle("particle1", 20.0f); }
private void OnDestroy() { PhysicsNativePlugin.DestroyPhysicsWorld(); }