// 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); }
// 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; }
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); }
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); }
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; }
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; }
/* * 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; }
void Start() { body = this.GetComponent <FauxGravityBody>(); rigidBody = this.GetComponent <Rigidbody>(); }
private Animator m_Animator; //reference to animator on object void Start() { m_Rigid = GetComponent <Rigidbody>(); m_Animator = GetComponent <Animator>(); m_fauxBody = GetComponent <FauxGravityBody>(); }
void Start() { myBody = GetComponent <FauxGravityBody> (); }