Search Unity

Fish Attack

Discussion in 'Scripting' started by potter3366, Sep 21, 2010.

  1. potter3366

    potter3366

    Joined:
    Oct 15, 2009
    Posts:
    65
    I'm trying to make simple AI for an enemy character. It is a piranha fish that will patrol inside box area.
    I'd like to have one fixed camera and fish will react on a mouse click.
    When a mouse click is detected, apply attack piranha animation in the mouse position (Raycasting).
    When there is no mouse action, fish go back to their path (random waypoints ?) and play idle or swim piranha animations.
    Please for any suggestion, where to start, which scripts to use and what's the best way make the curve animation smooth?

    Thanx Andeeee for PM
     
  2. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    It looks like maybe you already got an answer (?), but if you're still looking for suggestions, steering behaviors are often used to create the type of behavior you're describing. For the scenario you describe, the 'wander' and 'obstacle avoidance' steering behaviors would likely produce reasonable results. If there's more than one fish, you could also incorporate flocking behaviors.

    Attacking the target point can be accomplished with steering behaviors as well.
     
  3. OXYGEN

    OXYGEN

    Guest

    Joined:
    Mar 16, 2008
    Posts:
    1,101
    check out the old fps script its lurking around some were just google fps tutorial unity
    the ai system incorparated can be modified to fit your needs
     
  4. potter3366

    potter3366

    Joined:
    Oct 15, 2009
    Posts:
    65
    In FPS tutorial robots are moving along XZ axis.
    My fish has all 3 directions free and such movement require smooth animation..
    What does it mean now? Does I have to update dynamically spline controller (my idea was to generate random waypoints to simulating fish behaviour)??

    Andeeee wrote:

    "You may find Bezier curves or Catmull-Rom splines easier to use if you need to modify the motion path on the fly"

    Does anyone have experience with this?
     
  5. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    I would try steering behaviors first, as I suggested previously. If that doesn't seem like a suitable solution, perhaps you could explain in what way it doesn't meet your needs (as that would make it easier to provide useful suggestions).

    But yes, you could also use splines for this. If you have specific questions about the spline-based approach, just post them here and someone should be able to help.