Ejemplo n.º 1
0
 public PhysicDebugObject()
 {
     Body = new PhysicBody(new Rectangle(0, 0, 16, 16), Position);
     Body.Sensors.Add(new PhysicSensor(new Rectangle(-3, 0, 3, 16)));   //Left
     Body.Sensors.Add(new PhysicSensor(new Rectangle(0, -3, 16, 3)));   //Top
     Body.Sensors.Add(new PhysicSensor(new Rectangle(16, 0, 3, 16)));   //Right
     Body.Sensors.Add(new PhysicSensor(new Rectangle(0, 16, 16, 3)));   //Bottom
 }
Ejemplo n.º 2
0
    bool DestroyObject(PhysicBody attractObj)
    {
        if (GetComponent <PhysicBody>().mass < attractObj.mass)
        {
            OnRemoveObj();
            Destroy(gameObject);
            return(true);
        }

        return(false);
    }
Ejemplo n.º 3
0
    private void OnCollisionEnter(Collision collision)
    {
        //acceleration = Vector3.zero;
        //accelerationRelative = Vector3.zero;
        //velocity = Vector3.zero;
        //sumForces = Vector3.zero;

        PhysicBody pb = collision.gameObject.GetComponent <PhysicBody>();

        if (pb != null)
        {
            DestroyObject(pb);
        }
    }
Ejemplo n.º 4
0
 void Start()
 {
     rb          = GetComponent <Rigidbody>();
     physicBody  = GetComponent <PhysicBody>();
     limbs       = new List <Limb>();
     limbMembers = new List <LimbMember>();
     Limb[] arrayLimbs = GetComponentsInChildren <Limb>();
     foreach (Limb lm in arrayLimbs)
     {
         limbs.Add(lm);
     }
     LimbMember[] arrayMems = GetComponentsInChildren <LimbMember>();
     foreach (LimbMember lm in arrayMems)
     {
         limbMembers.Add(lm);
     }
     feet = GetComponentsInChildren <Foot>();
 }
Ejemplo n.º 5
0
    // Use this for initialization
    public void init(float p_mass, float p_dist, float p_speed)
    {
        sun = GameObject.FindGameObjectWithTag("Sun");
        rb  = GetComponent <PhysicBody>();
        transform.eulerAngles = new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360));

        _initialMass     = p_mass;
        _initialDistance = p_dist;
        _initialSpeed    = p_speed;

        rb.mass = _initialMass;
        rb.AddRelativeForce(Vector3.forward * (_initialSpeed * 10));

        transform.position = RandomCircle(sun.transform.position, _initialDistance);
        lastPos            = transform.position;

        minDist = 999999;
    }
Ejemplo n.º 6
0
    void Attract(Attract3D objToAttract)
    {
        PhysicBody rbToAttract = objToAttract.rb;

        Vector3 direction = rb.transform.position - rbToAttract.transform.position;
        float   distance  = direction.magnitude;

        if (distance == 0f)
        {
            return;
        }

        float   forceMagnitude = G * (rb.mass * rbToAttract.mass) / Mathf.Pow(distance, 2);
        Vector3 force          = direction.normalized * forceMagnitude;

        transform.rotation = Quaternion.LookRotation(-direction.normalized, Vector3.up);

        rbToAttract.AddRelativeForce(force);
    }
Ejemplo n.º 7
0
 private void Awake()
 {
     rb = GetComponent <PhysicBody>();
 }
Ejemplo n.º 8
0
 void Awake()
 {
     pb = GetComponent <PhysicBody>();
     am = GetComponent <Animator>();
 }
Ejemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     teste      = GetComponent <PhysicBody>();
     teste.mass = 1;
 }