Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Using Transform.Translate vs AddForce for an AI Character

Discussion in 'Scripting' started by gk104, Apr 14, 2017.

  1. gk104

    gk104

    Joined:
    Apr 25, 2014
    Posts:
    57
    Hi. currently I'm working on a 2D game project which consisting of AI Characters that have the ability to walk, attack, die etc..

    I already have made a script for making the AI walk around using RigidBody.Addforce, problem is that I'm not sure whatever functions or classes should I use for 2D AI movement.
    As far as I know there are several ways for that, Transform.Translate, Rigidbody.AddForce, or Vector2.MoveTowards,
    and I'm really confused and not sure whatever way should I use for a basic AI Movement in 2D Project, what are the differences between all these ways, and if there is any difference in performance, or limitations in using a specific way.
    I'll be glad if someone would explain in detail.
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,496
  3. gk104

    gk104

    Joined:
    Apr 25, 2014
    Posts:
    57
  4. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,496
    Do the AI Characters have a Rigidbody and Collider? Then yes.