예제 #1
0
    private void Awake()
    {
        // Assigning all the gameobjects that our goat needs to interact with.
        _mountain = GameObject.Find("Mountain").GetComponent <Mountain>();
        _ground   = GameObject.Find("GroundMesh").GetComponent <Ground>();
        _cannon   = GameObject.Find("GoatCannon").GetComponent <Cannon>();
        _forces   = GameObject.Find("Environment Forces").GetComponent <EnvironmentForces>();

        // Extracting the attributes needed for physics.
        _angle            = _cannon.Angle;
        _initialVelocity  = _cannon.Velocity;
        _gravity          = _forces.Gravity;
        _airResistance    = _forces.AirResistance;
        _myVerlets        = new List <Verlet>();
        _mountainVertices = new List <Vector3>();
        _groundVertices   = new List <Vector3>();
        _lines            = new List <LineRenderer>();

        CreateVerlets();
        // Initialize the forces acting upon the verlet(s) to be 0 at start.
        foreach (var verlet in _myVerlets)
        {
            verlet.CurrentForce = Vector3.zero;
        }
    }
예제 #2
0
 // Use this for initialization
 private void Start()
 {
     _cannon = GameObject.Find(ProjectileType.ToString() + "Cannon").GetComponent <Cannon>();
     _forces = GameObject.Find("Environment Forces").GetComponent <EnvironmentForces>();
     // Compoenent Initial velocity
     // Vx = Vi * Cos(Theta)
     // Vy = Vi * Sin(Theta)
     _velocity.x = _cannon.Velocity * Mathf.Cos(Mathf.Deg2Rad * _cannon.Angle);
     _velocity.y = _cannon.Velocity * Mathf.Sin(Mathf.Deg2Rad * _cannon.Angle);
     if (ProjectileType == ProjectileType.Goat)
     {
         _velocity.x = -_velocity.x;
     }
 }