public static void WMSK_LookAt(this GameObject o, Vector2 destination) { GameObjectAnimator anim = o.GetComponent <GameObjectAnimator>(); if (anim == null) { return; } anim.LookAt(destination); }
/// <summary> /// Fires a bullet, cannon-ball, missile, etc. /// </summary> /// <param name="bullet">Bullet. You must supply your own bullet gameobject.</param> /// <param name="startAnchor">Start anchor. Where does the bullet appear? This vector3 is expressed in local coordinates of the firing unit and ignores its scale.</param> /// <param name="destination">Destination. Target 2d map coordinates.</param> /// <param name="duration">Duration for the bullet to reach its destination..</param> /// <param name="arcMultiplier">Pass a value greater than 1 to produce a parabole.</param> /// <param name="delay">Firing delay. Gives time to the unit so it can orient to target.</param> /// <param name="orientToTarget">Orient to target before firing.</param> /// <param name="testAnchor">Drops the bullet at the start of the trajectory. Useful to check the anchor is correct.</param> public static GameObjectAnimator WMSK_Fire(this GameObject o, GameObject bullet, Vector3 startAnchor, Vector2 destination, float bulletSpeed, float arcHeight = 1f, float delay = 1f, bool orientToTarget = true, bool testAnchor = false) { GameObjectAnimator goAnim = o.GetComponent <GameObjectAnimator>(); if (goAnim == null) { return(null); } if (orientToTarget) { goAnim.LookAt(destination); } return(goAnim.Fire(delay, bullet, startAnchor, destination, bulletSpeed, arcHeight, testAnchor)); }