Пример #1
0
 // Start is called before the first frame update
 void Start()
 {
     oldPosition    = model.transform.position - model.transform.up * distance;
     newPosition    = model.transform.position + model.transform.up * distance;
     rig            = GetComponent <Rigidbody>();
     body           = GetComponent <FauxGravityBody>();
     gemCollider    = GetComponent <BoxCollider>();
     body.attractor = planet;
     AkSoundEngine.PostEvent("gema_spawn", spawnSound);
 }
Пример #2
0
    // Start is called before the first frame update
    private void Start()
    {
        rig            = GetComponent <Rigidbody>();
        mesh           = GetComponent <MeshRenderer>();
        fauxBody       = GetComponent <FauxGravityBody>();
        colliderMeteor = GetComponent <SphereCollider>();

        dirFrom            = from.transform.position;
        transform.position = dirFrom;
    }
Пример #3
0
    public void Attract(FauxGravityBody body)
    {
        Vector3 gravityUp = (body.transform.position - transform.position).normalized;

        // calculate gravity according to F = (GMm)/(r^2)
        float r = (body.transform.position - transform.position).magnitude;
        float F = Mathf.Max((1 - r / radius), 0) * GRAVITY;

        body.rb.AddForce(-gravityUp * F);
    }
    public void Attract(FauxGravityBody body)
    {
        Vector3 gravityUp = (body.transform.position - transform.position).normalized;

        // calculate gravity according to F = (GMm)/(r^2)
        float r = (body.transform.position - transform.position).magnitude;
        float F = (GRAVITY * mass * body.mass) / (r * r);

        body.rb.AddForce(-gravityUp * F);
        // body.rb.AddForce(-gravityUp * F * Time.deltaTime, ForceMode.Impulse);
    }
Пример #5
0
    public void Attract(FauxGravityBody body)
    {
        Vector3 gravityUp = (body.transform.position - transform.position).normalized;
        Vector3 bodyUp    = body.transform.up;

        body.rigidbody.AddForce(gravityUp * gravity);

        Quaternion targetRotation = Quaternion.FromToRotation(bodyUp, gravityUp) * body.transform.rotation;

        body.transform.rotation = Quaternion.Slerp(body.transform.rotation, targetRotation, rotationSpeedFactor * Time.deltaTime);
    }
Пример #6
0
 void Start()
 {
     CurrentGravityBody      = this.GetComponent <FauxGravityBody>();
     CurrentGravityAttractor = CurrentGravityBody.attractor;
     rb = this.GetComponent <Rigidbody>();
     PlayerAnimController = PlayerModel.GetComponent <AnimController>();
     currentMoveDirection = Direction.still;
     CurrentSpeedMovement = SpeedMovement.Idle;
     rb.useGravity        = false; // Disables Gravity
     rb.constraints       = RigidbodyConstraints.FreezeRotation;
     // controller sided;
 }
Пример #7
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
            return;
        }

        outline       = GetComponent <Outline>();
        outline.color = 1;

        body         = GetComponent <FauxGravityBody>();
        body.enabled = false;
        m_Material   = GetComponentInChildren <Renderer>().material;
    }
Пример #8
0
    /*
     * Public attract class method
     */
    public void Attract(FauxGravityBody body)
    {
        // Create local variables
        Vector3 gravityUp;
        Transform trans = body.transform;
        Rigidbody rigid = body.rigidbody;

        // Set gravity local variable
        gravityUp = trans.position - this.transform.position;
        gravityUp.Normalize();

        // Apply forces to body
        rigid.AddForce(gravityUp * this.m_Gravity * rigid.mass);

        // Check value of bodys grounded value
        if(body.Grounded >= 1)
        {
            // Set rigid body drag
            rigid.drag = 0.1f;
        }
        else
        {
            // Set rigid body drag
            rigid.drag = 1.0f;
        }

        // Check value of rotation freeze
        if(rigid.freezeRotation == true)
        {
            // Calculate quaternion
            Quaternion quatern = Quaternion.FromToRotation(trans.up, gravityUp);
            quatern = quatern * trans.rotation;

            // Calculate rotation of body
            trans.rotation = Quaternion.Slerp(trans.rotation, quatern, 0.1f);
        }
    }
 void Start()
 {
     planetCtrl      = GameObject.FindGameObjectWithTag("Planet").GetComponent <FauxGravityBody>();
     rb              = GetComponent <Rigidbody2D>();
     rb.gravityScale = 0f;
 }
Пример #10
0
 void Start()
 {
     body      = this.GetComponent <FauxGravityBody>();
     rigidBody = this.GetComponent <Rigidbody>();
 }
Пример #11
0
    private Animator m_Animator;    //reference to animator on object

    void Start()
    {
        m_Rigid    = GetComponent <Rigidbody>();
        m_Animator = GetComponent <Animator>();
        m_fauxBody = GetComponent <FauxGravityBody>();
    }
Пример #12
0
 void Start()
 {
     myBody = GetComponent <FauxGravityBody> ();
 }