// Use this for initialization
            private void Start()
            {
                originalStructure = new List<Transform> (GetComponentsInChildren<Transform> ());
                originalPosition = transform.position;
                originalRotation = transform.rotation;

                Rigidbody = GetComponent<Rigidbody> ();
            }
示例#2
0
            public static _3D_ATTRIBUTES to3DAttributes(GameObject go, Rigidbody rigidbody = null)
            {
                FMOD.Studio._3D_ATTRIBUTES attributes = new FMOD.Studio._3D_ATTRIBUTES();
                attributes.forward = toFMODVector(go.transform.forward);
                attributes.up = toFMODVector(go.transform.up);
                attributes.position = toFMODVector(go.transform.position);

                if (rigidbody)
                    attributes.velocity = toFMODVector(rigidbody.velocity);

                return attributes;
            }
		private static void INTERNAL_CALL_MovePosition(Rigidbody self, ref Vector3 position){}
示例#4
0
 public void Start()
 {
     this.enemiesInAttackRange = new List<BaseUnit>();
     this.removeList = new List<BaseUnit>();
     this.exitedList = new List<BaseUnit>();
     this.parent = this.GetComponentInParent<GameUnit>();
     this.sphereColliderRigidBody = this.GetComponent<Rigidbody>();
     this.otherEnemies = new List<BaseUnit>();
 }
示例#5
0
 /// <inheritdoc/>
 protected internal override bool IsValidParent(Rigidbody parent)
 {
     // Triangle mesh colliders cannot be used for non-kinematic rigidbodies
     return mesh == null|| mesh.MeshType == PhysicsMeshType.Convex || parent.Kinematic;
 }
		private static Vector3 INTERNAL_CALL_GetPointVelocity(Rigidbody self, ref Vector3 worldPoint){}
示例#7
0
        void Start()
        {
            tr = transform;
            rb = (Rigidbody)F.GetTopmostParentComponent <Rigidbody>(tr);
            vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(tr);
            suspensionParent    = tr.parent.GetComponent <Suspension>();
            travelDist          = suspensionParent.targetCompression;
            canDetach           = detachForce < Mathf.Infinity && Application.isPlaying;
            initialTirePressure = tirePressure;

            if (tr.childCount > 0)
            {
                //Get rim
                rim = tr.GetChild(0);

                //Set up rim glow material
                if (rimGlow > 0 && Application.isPlaying)
                {
                    rimMat = new Material(rim.GetComponent <MeshRenderer>().sharedMaterial);
                    rimMat.EnableKeyword("_EMISSION");
                    rim.GetComponent <MeshRenderer>().material = rimMat;
                }

                //Create detached wheel
                if (canDetach)
                {
                    detachedWheel           = new GameObject(vp.transform.name + "'s Detached Wheel");
                    detachedWheel.layer     = LayerMask.NameToLayer("Detachable Part");
                    detachFilter            = detachedWheel.AddComponent <MeshFilter>();
                    detachFilter.sharedMesh = rim.GetComponent <MeshFilter>().sharedMesh;
                    MeshRenderer detachRend = detachedWheel.AddComponent <MeshRenderer>();
                    detachRend.sharedMaterial = rim.GetComponent <MeshRenderer>().sharedMaterial;
                    detachedCol        = detachedWheel.AddComponent <MeshCollider>();
                    detachedCol.convex = true;
                    detachedBody       = detachedWheel.AddComponent <Rigidbody>();
                    detachedBody.mass  = mass;
                }

                //Get tire
                if (rim.childCount > 0)
                {
                    tire = rim.GetChild(0);
                    if (deformAmount > 0 && Application.isPlaying)
                    {
                        tireMat = new Material(tire.GetComponent <MeshRenderer>().sharedMaterial);
                        tire.GetComponent <MeshRenderer>().material = tireMat;
                    }

                    //Create detached tire
                    if (canDetach)
                    {
                        detachedTire = new GameObject("Detached Tire");
                        detachedTire.transform.parent        = detachedWheel.transform;
                        detachedTire.transform.localPosition = Vector3.zero;
                        detachedTire.transform.localRotation = Quaternion.identity;
                        detachTireFilter            = detachedTire.AddComponent <MeshFilter>();
                        detachTireFilter.sharedMesh = tire.GetComponent <MeshFilter>().sharedMesh;
                        MeshRenderer detachTireRend = detachedTire.AddComponent <MeshRenderer>();
                        detachTireRend.sharedMaterial = tireMat ? tireMat : tire.GetComponent <MeshRenderer>().sharedMaterial;
                    }
                }

                if (Application.isPlaying)
                {
                    //Generate hard collider
                    if (generateHardCollider)
                    {
                        GameObject sphereColNew = new GameObject("Rim Collider");
                        sphereColNew.layer        = GlobalControl.ignoreWheelCastLayer;
                        sphereColTr               = sphereColNew.transform;
                        sphereCol                 = sphereColNew.AddComponent <SphereCollider>();
                        sphereColTr.parent        = tr;
                        sphereColTr.localPosition = Vector3.zero;
                        sphereColTr.localRotation = Quaternion.identity;
                        sphereCol.radius          = Mathf.Min(rimWidth * 0.5f, rimRadius * 0.5f);
                        sphereCol.material        = GlobalControl.frictionlessMatStatic;
                    }

                    if (canDetach)
                    {
                        detachedWheel.SetActive(false);
                    }
                }
            }

            targetDrive = GetComponent <DriveForce>();
            currentRPM  = 0;
        }
		private static RaycastHit[] INTERNAL_CALL_SweepTestAll(Rigidbody self, ref Vector3 direction, float distance){}
		private static void INTERNAL_CALL_AddForceAtPosition(Rigidbody self, ref Vector3 force, ref Vector3 position, ForceMode mode){}
示例#10
0
 private void Start()
 {
     ani = GetComponent<Animator>();
     rig = GetComponent<Rigidbody>();
 }
示例#11
0
 // Start is called before the first frame update
 void Start()
 {
     rig     = GetComponent <Rigidbody>();
     Gravity = new Vector3(0, -9.8f, 0);
 }
 public void ActivateAndPull(Rigidbody rb)
 {
     affectedRigidbodies.Add(rb);
 }
 public void RemoveFromPull(Rigidbody rb)
 {
     affectedRigidbodies.Remove(rb);
 }
示例#14
0
 void Start()
 {
     _playerRigidbody = FindObjectOfType <PlayerController>().GetComponent <Rigidbody>();
     EventManager.Instance.StartListening(TouchEvent.EventName, OnTouch);
 }
 void Awake()
 {
     rigidbody    = GetComponent <Rigidbody> ();
     rigidbodyFPC = GetComponent <RigidbodyFirstPersonController> ();
     headBob      = GetComponentInChildren <HeadBob> ();
 }
 // Use this for initialization
 void Start()
 {
     _rb             = gameObject.GetComponent <Rigidbody>();
     _player         = GameObject.Find("Player").transform;
     _spriteRenderer = GetComponent <SpriteRenderer>();
 }
示例#17
0
		private static void INTERNAL_CALL_Sleep(Rigidbody self){}
示例#18
0
 void Start()
 {
     RigidBody    = GetComponent <Rigidbody>();
     MonsterState = MonsterState.IDLE;
 }
示例#19
0
		private static void INTERNAL_CALL_WakeUp(Rigidbody self){}
示例#20
0
 void Start()
 {
     enemyRb = GetComponent <Rigidbody>();
     player  = GameObject.Find("Player");
 }
示例#21
0
		private static void INTERNAL_CALL_AddForce(Rigidbody self, ref Vector3 force, ForceMode mode){}
 private void Awake()
 {
   this.m_RigidBody3D = this.GetComponent<Rigidbody>();
   this.m_RigidBody2D = this.GetComponent<Rigidbody2D>();
   this.m_CharacterController = this.GetComponent<CharacterController>();
   this.m_PrevPosition = this.transform.position;
   this.m_PrevRotation = this.transform.rotation;
   this.m_PrevVelocity = 0.0f;
   if (!this.localPlayerAuthority)
     return;
   this.m_LocalTransformWriter = new NetworkWriter();
 }
示例#23
0
		private static Vector3 INTERNAL_CALL_ClosestPointOnBounds(Rigidbody self, ref Vector3 position){}
示例#24
0
 void Awake()
 {
     body            = GetComponent <Rigidbody>();
     body.useGravity = false;
     OnValidate();
 }
示例#25
0
 void Start()
 {
     rb   = GetComponent <Rigidbody>();
     bull = GameObject.FindGameObjectWithTag("Player").GetComponent <Bullet>();
     time = FindObjectOfType <TimeManager>();
 }
示例#26
0
文件: Player.cs 项目: nick55660711/TM
 private void Awake()
 {
     rig = GetComponent <Rigidbody>();
     cam = transform.GetChild(0);
 }
示例#27
0
        protected override bool DetectSetup()
        {
            finalDirection = (direction == ButtonDirection.autodetect ? DetectDirection() : direction);
            if (finalDirection == ButtonDirection.autodetect)
            {
                activationDir = Vector3.zero;
                return false;
            }
            if (direction != ButtonDirection.autodetect)
            {
                activationDir = CalculateActivationDir();
            }

            if (buttonForce)
            {
                buttonForce.force = GetForceVector();
            }

            if (Application.isPlaying)
            {
                buttonJoint = GetComponent<ConfigurableJoint>();

                bool recreate = false;
                Rigidbody oldBody = null;
                Vector3 oldAnchor = Vector3.zero;
                Vector3 oldAxis = Vector3.zero;

                if (buttonJoint)
                {
                    // save old values, needs to be recreated
                    oldBody = buttonJoint.connectedBody;
                    oldAnchor = buttonJoint.anchor;
                    oldAxis = buttonJoint.axis;
                    DestroyImmediate(buttonJoint);
                    recreate = true;
                }

                // since limit applies to both directions object needs to be moved halfway to activation before adding joint
                transform.position = transform.position + ((activationDir.normalized * activationDistance) * 0.5f);
                buttonJoint = gameObject.AddComponent<ConfigurableJoint>();

                if (recreate)
                {
                    buttonJoint.connectedBody = oldBody;
                    buttonJoint.anchor = oldAnchor;
                    buttonJoint.axis = oldAxis;
                }
                if (connectedTo)
                {
                    buttonJoint.connectedBody = connectedTo.GetComponent<Rigidbody>();
                }

                SoftJointLimit buttonJointLimits = new SoftJointLimit();
                buttonJointLimits.limit = activationDistance * 0.501f; // set limit to half (since it applies to both directions) and a tiny bit larger since otherwise activation distance might be missed
                buttonJoint.linearLimit = buttonJointLimits;

                buttonJoint.angularXMotion = ConfigurableJointMotion.Locked;
                buttonJoint.angularYMotion = ConfigurableJointMotion.Locked;
                buttonJoint.angularZMotion = ConfigurableJointMotion.Locked;
                buttonJoint.xMotion = ConfigurableJointMotion.Locked;
                buttonJoint.yMotion = ConfigurableJointMotion.Locked;
                buttonJoint.zMotion = ConfigurableJointMotion.Locked;

                switch (finalDirection)
                {
                    case ButtonDirection.x:
                    case ButtonDirection.negX:
                        if (Mathf.RoundToInt(Mathf.Abs(transform.right.x)) == 1)
                        {
                            buttonJoint.xMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.up.x)) == 1)
                        {
                            buttonJoint.yMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.forward.x)) == 1)
                        {
                            buttonJoint.zMotion = ConfigurableJointMotion.Limited;
                        }
                        break;
                    case ButtonDirection.y:
                    case ButtonDirection.negY:
                        if (Mathf.RoundToInt(Mathf.Abs(transform.right.y)) == 1)
                        {
                            buttonJoint.xMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.up.y)) == 1)
                        {
                            buttonJoint.yMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.forward.y)) == 1)
                        {
                            buttonJoint.zMotion = ConfigurableJointMotion.Limited;
                        }
                        break;
                    case ButtonDirection.z:
                    case ButtonDirection.negZ:
                        if (Mathf.RoundToInt(Mathf.Abs(transform.right.z)) == 1)
                        {
                            buttonJoint.xMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.up.z)) == 1)
                        {
                            buttonJoint.yMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.forward.z)) == 1)
                        {
                            buttonJoint.zMotion = ConfigurableJointMotion.Limited;
                        }
                        break;
                }
            }

            return true;
        }
示例#28
0
 void Start()
 {
     body  = GetComponent <Rigidbody>();
     sound = GetComponent <AudioSource>();
     PreLaunch();
 }
示例#29
0
 // Start is called before the first frame update
 void Start()
 {
     rb       = GetComponent <Rigidbody>();
     Grounded = true;
 }
        public static void AttachInstanceToGameObject(FMOD.Studio.EventInstance instance, Transform transform, Rigidbody rigidBody)
        {
            var attachedInstance = new AttachedInstance();

            attachedInstance.transform = transform;
            attachedInstance.instance  = instance;
            attachedInstance.rigidBody = rigidBody;
            Instance.attachedInstances.Add(attachedInstance);
        }
示例#31
0
 /// <inheritdoc/>
 protected internal override bool IsValidParent(Rigidbody parent)
 {
     // Planes cannot be added to non-kinematic rigidbodies
     return parent.Kinematic;
 }
 public static void SetListenerLocation(GameObject gameObject, Rigidbody rigidBody = null)
 {
     Instance.studioSystem.setListenerAttributes(0, RuntimeUtils.To3DAttributes(gameObject, rigidBody));
 }
示例#33
0
 // Use this for initialization
 void Awake()
 {
     mPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent<CPlayerCtrl>();
     mRigidbody = GetComponent<Rigidbody>();
 }
示例#34
0
文件: PickUp.cs 项目: carodak/Maze
 void Start()
 {
     rb = GetComponent <Rigidbody>(); //use the rigidbody component to get our object
 }
示例#35
0
		private static void INTERNAL_CALL_MoveRotation(Rigidbody self, ref Quaternion rot){}
示例#36
0
 void Start()
 {
     force     = 500;
     rigidBody = GetComponent <Rigidbody>();
     rigidBody.AddExplosionForce(force, transform.position + Random.insideUnitSphere * 5, 20, 20);
 }
示例#37
0
		private static bool INTERNAL_CALL_IsSleeping(Rigidbody self){}
示例#38
0
 public override void OnEnable() => Component = gameObject.GetComponent <Rigidbody>();
示例#39
0
		private static bool INTERNAL_CALL_SweepTest(Rigidbody self, ref Vector3 direction, out RaycastHit hitInfo, float distance){}
    private float powerupStrength = 25; // how hard to hit enemy with powerup

    void Start()
    {
        playerRb   = GetComponent <Rigidbody>();
        focalPoint = GameObject.Find("Focal Point");
    }
示例#41
0
		private static void INTERNAL_CALL_SetDensity(Rigidbody self, float density){}
 void Start()
 {
     Destroy(gameObject, 60);
     rb = GetComponent <Rigidbody>();
 }
示例#43
0
		private static void INTERNAL_CALL_AddRelativeTorque(Rigidbody self, ref Vector3 torque, ForceMode mode){}
 void Start()
 {
     rb = GetComponent <Rigidbody>();
     transform.parent = null;
 }
示例#45
0
		private static void INTERNAL_CALL_AddExplosionForce(Rigidbody self, float explosionForce, ref Vector3 explosionPosition, float explosionRadius, float upwardsModifier, ForceMode mode){}
 void Start()
 {
     thisRigidbody  = GetComponent <Rigidbody>();
     Cursor.visible = false;
 }
示例#47
0
		private static Vector3 INTERNAL_CALL_GetRelativePointVelocity(Rigidbody self, ref Vector3 relativePoint){}
示例#48
0
 /// <summary>
 /// Connect new car joint to front car
 /// </summary>
 /// <param name="newTrainCar"></param>
 /// <param name="previousCarCoupler"></param>
 public static void ConnectTrainCar(HingeJoint newTrainCar, Rigidbody frontCarCoupler)
 {
     newTrainCar.connectedBody = frontCarCoupler;
 }
示例#49
0
 //////////////////////////////////////////////////////////////////////////////
 //                                                                          //
 //Unity Functions                                                           //
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
 // Use this for initialization
 void Start()
 {
     rb = GetComponent<Rigidbody>();
 }
示例#50
0
 // Start is called before the first frame update
 void Start()
 {
     rigidbodyComponent = GetComponent <Rigidbody>();
 }
 private void SetupRigidbody(bool isKinematic)
 {
     rigidbody = new Rigidbody(position, size, isKinematic);
 }
示例#52
0
 private void Start()
 {
     rb = GetComponent <Rigidbody>();
 }
示例#53
0
 // Start is called before the first frame update
 void Start()
 {
     RB = GetComponent <Rigidbody>();
 }
示例#54
0
 private void Start()
 {
     this._board      = PlayerController.Instance.boardController.boardRigidbody;
     this._backTruck  = PlayerController.Instance.boardController.backTruckRigidbody;
     this._frontTruck = PlayerController.Instance.boardController.frontTruckRigidbody;
 }