Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
How to make a sprite follow the CLOSEST sprite of another tag? Javascript

I am trying to simulate evolution and while Im waiting to learn a little more about AI I want to get the organisms to move towards the closest piece of food with the tag "Food".

I made this file to add onto the spawn of each organism so it will move towards food but it tries to move towards all of them at once

Javascript, Kaboom.js, Replit.com

// custom component controlling organim movement
export default function MoveToFood() {
    return {
        id: "MoveToFood",
        require: ["pos", "area",],
        add() {
            //Start organism move towards food
            onUpdate("Food", (f) => {
                dir = f.pos.sub(this.pos).unit();
                this.move(dir.scale(Speed));
            })
            this.onUpdate(() => {
                Starve -= 1;
                if (Starve <= 0) {
                    destroy(this)
                }
            })
        },
    }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!