Пример #1
0
 void Start()
 {
     rbody         = this.gameObject.GetComponent <Rigidbody>();
     planning      = PersonalPlanning.instance;
     originalSpeed = runSpeed;
     weight        = planning.GetWeightP1();
     oldWeight     = weight;
     runSpeed     -= weight * runSpeed;
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        weight = planning.GetWeightP1();
        Debug.Log(weight);
        Debug.Log(runSpeed);
        if (weight != oldWeight)
        {
            runSpeed  = originalSpeed - (weight * originalSpeed);
            oldWeight = weight;
        }
        //weight = planning.GetWeightP1();
        if (!walled)
        {
            if (Input.GetKeyDown(KeyCode.D))
            {
                runMod = 1f;
            }
            if (Input.GetKeyDown(KeyCode.A))
            {
                runMod = -1f;
            }
            if (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.D))
            {
                runMod = 0;
            }
        }

        rbody.velocity = new Vector3(runMod * runSpeed, rbody.velocity.y, 0);

        if (Input.GetKey(KeyCode.W) && grounded)
        {
            Debug.Log("jump");
            rbody.velocity = new Vector3(runSpeed * runMod, jumpSpeed, 0);
            grounded       = false;
            //rbody.AddForce(new Vector3(50, jumpSpeed, 0));
        }
        if (!grounded)
        {
            Vector3 extraGravityForce = (Physics.gravity * 1.5f) - Physics.gravity;
            rbody.AddForce(extraGravityForce);
        }
    }
Пример #3
0
 public void UpdateSpeed()
 {
     weight    = planning.GetWeightP1();
     runSpeed -= weight * runSpeed;
 }