Пример #1
0
    // Use this for initialization
    void Start()
    {
        rb                 = GetComponent <Rigidbody> ();
        motionField        = mapConstraints.objectMotionField;
        eulerAngleVelocity = new Vector3(
            Random.Range(-1, 1),
            Random.Range(-1, 1),
            Random.Range(-1, 1)
            );

        eulerAngleVelocity = eulerAngleVelocity.normalized * rotationalVelocity;

        float x = Random.Range(-1.0f, 1.0f);
        float y = Random.Range(-1.0f, 1.0f);
        float z = Random.Range(-1.0f, 1.0f);

        switch (motionField)
        {
        case ObjectRangeOfMotion.PLANAR:
            dir = new Vector3(x, 0, z);
            break;

        case ObjectRangeOfMotion.FULL_3D:
            dir = new Vector3(x, y, z);
            break;
        }

//		speed = Random.Range ( -5, 5 );

        rb.velocity = (dir.normalized * speed);
        rb.AddTorque(eulerAngleVelocity * rb.mass, ForceMode.Impulse);
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        rb = GetComponent <Rigidbody> ();
        rb.maxAngularVelocity = 50;
        speed               = startSpeed;
        motionField         = mapConstraints.objectMotionField;
        axisOfPlay          = mapConstraints.axisOfPlay;
        english             = Vector3.zero;
        collisionEffectInst = Instantiate(collisionEffect);
        collisionParticles  = collisionEffectInst.GetComponent <ParticleSystem>();

        if (motionField == ObjectRangeOfMotion.PLANAR)
        {
            rbConstraints = RigidbodyConstraints.FreezePositionY;
        }

        rb.constraints = RigidbodyConstraints.FreezeAll;

        ScoreManager.playerScore = 0;            //Emily
        ScoreManager.enemyScore  = 0;            //Emily
    }