예제 #1
0
파일: Gem.cs 프로젝트: frankvega2010/Fee
 // 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
파일: Bullet.cs 프로젝트: frankvega2010/Fee
    // 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> ();
 }