Ejemplo n.º 1
0
    private Vector3 currentRigidGravity; //TODO do not use in future! use our system. unless you decide otherwise. this could actually work?

    //TODO In future move drag etc. to modular outside modifiable behaviour effecting system. have this system be called by events etc. in here to adjust speeds etc etc. so yeah modular behaviour etc. system! we can then truly have customizable physics

    #region Initialization

    private void Start()
    {
        activeRigidBody = GetComponent <Rigidbody>();
        if (activeRigidBody != null && !activeRigidBody.isKinematic)
        {
            isRigid = true;
        }

        characterController = GetComponent <CharacterController>();
        if (!isRagdoll)
        {
            activeGravityForce = new CustomTraditionalForce(GameProperties.Singleton.BaseGravity * gravityMultiplier);
        }
        else
        {
            //TODO Dont do this in proper physics system onec its fully implemented. official standard components should handle this stuff! Maybe. Dont waste too much time but yea it should work
            activeGravityForce = new CustomTraditionalForce(Vector3.zero);

            activeRigidBody.useGravity = true;
            activeRigidBody.AddForce(GameProperties.Singleton.BaseGravity * gravityMultiplier - Physics.gravity);
            currentRigidGravity = GameProperties.Singleton.BaseGravity * gravityMultiplier;
        }

        new CustomForce(this, activeGravityForce, true, float.NegativeInfinity);

        objectDragValue          = GameManager.Singleton.GetLevelDefaultDragValue();
        adjustedTrueMaximumSpeed = objectDragValue * dragResistanceMultiplier;

        InitializeAppropriateForceCoroutine();
    }
Ejemplo n.º 2
0
    public void ExecuteInstantaniousForce(KeyCode forceKeyCode)
    {
        if (CanExertMotorForce())
        {
            if (acceptedInstantaniousGroundedForceInputs.ContainsKey(forceKeyCode))
            {
                HumanoidComponentExclusiveAdjustableForceInformationWithKnownObject info = acceptedInstantaniousGroundedForceInputs[forceKeyCode];

                if (info.GetCurrentCooldown() <= 0)
                {
                    info.SetCurrentCooldown(info.applyCooldown);
                    if (info.animationFlag != "")
                    {
                        humanoidAnimator.SetTrigger(info.animationFlag);
                    }
                    CustomTraditionalForce force = new CustomTraditionalForce(affectedForceObject.transform.localToWorldMatrix * info.v);
                    force.ApplyForce(affectedForceObject, info.isPure, info.infiniteTimeForce ? float.NegativeInfinity : info.applyTime);
                }
            }
        }
        else
        {
            if (acceptedInstantaniousLevitatingForceInputs.ContainsKey(forceKeyCode))
            {
                HumanoidComponentExclusiveAdjustableForceInformationWithKnownObject info = acceptedInstantaniousLevitatingForceInputs[forceKeyCode];

                if (info.GetCurrentCooldown() <= 0)
                {
                    info.SetCurrentCooldown(info.applyCooldown);
                    if (info.animationFlag != "")
                    {
                        humanoidAnimator.SetTrigger(info.animationFlag);
                    }
                    CustomTraditionalForce force = new CustomTraditionalForce(affectedForceObject.transform.localToWorldMatrix * info.v);
                    force.ApplyForce(affectedForceObject, info.isPure, info.infiniteTimeForce ? float.NegativeInfinity : info.applyTime);
                }
            }
        }
    }
Ejemplo n.º 3
0
    //Shoots the gun
    //Plays muzzleFlash animation and uses Raycast to hit object
    void Shoot()
    {
        muzzleFlash.Play();

        GameObject bulletObj;

        bulletObj = Instantiate(bullet, fpsCam.transform.position + fpsCam.transform.forward * 0.05f, fpsCam.transform.rotation);
        bulletObj.transform.forward = fpsCam.transform.forward;

        CustomTraditionalForce force = bulletObj.AddComponent <CustomTraditionalForce>();

        force.Force = fpsCam.transform.forward * bulletStartingForceMagnitude;

        force.ApplyForce(bulletObj.GetComponent <ForceObject>(), true, bulletForceApplicationTime);



        //RaycastHit hit;
        //var ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        //if (Physics.Raycast(ray, out hit, range))
        //{
        //    Debug.Log(hit.transform.name);
        //    // generates a bullet

        //    // the death hit
        //    // if (hit.rigidbody != null) {
        //    //     hit.rigidbody.AddForceAtPosition(ray.direction * power, hit.point);
        //    // }

        //    Target target = hit.transform.GetComponent<Target>();
        //    if (target != null) //If target is hit, turn damage on and send bool to GetHit under Target
        //    {
        //        damage = true;
        //        target.GetHit(damage);
        //    }
        //}
    }