Giter Site home page Giter Site logo

Multiple hide targets about kompute HOT 3 CLOSED

oguzeroglu avatar oguzeroglu commented on June 15, 2024
Multiple hide targets

from kompute.

Comments (3)

oguzeroglu avatar oguzeroglu commented on June 15, 2024

Hey @johnSamilin, thanks!

The implementation of hide behaviour is pretty simple:

// targetPosition is the position of the closest obstacle
return vectorPool.get().copy(hideableEntityPosition).sub(targetPosition).normalize().multiplyScalar(distanceAwayFromHideable).add(hideableEntityPosition);

So I'm not sure how this formula would work for multiple entities given its simplicity. Would we hide from the center point of each hide targets? We could alternatively draw an imaginary line from each hide target to the closest obstacle and find a point inside the imaginary area limited by these imaginary lines behind the obstacle however that seems geometrically more complex to implement.

I'd suggest you start simple first:

  • Create a dummy entity
  • Set this entity as the hide target
  • For each frame calculate the center point of each of your actual hide targets
  • dummyEntity.setPosition(centerPointYouCalculatedAbove)

so the hide behaviour would hide from the center point. Let's see if that works. If it does not, then I'd also consider implementing some sort of intelligence to my entity and just dynamically modify the hide target on the run based on some criteria (could be distance, whether it can be seen or not etc.).

from kompute.

oguzeroglu avatar oguzeroglu commented on June 15, 2024

calculate suitable hiding spot for each of the "enemy" entities and use the closest

This could work for some game but not for some other game depending on many factors (weapons, speed, type of the threat etc.) so it's better not to implement this in the library IMO. Maybe you should try creating a separate HideBehavior for each hide target, then combine these behaviors with a BlendedSteeringBehavior.

or just hide from the closest threatening entity.

Note that you could easily do that yourself in your game logic too by dynamically changing the hide target:
steerable.setHideTargetEntity(closestHideTarget);

from kompute.

johnSamilin avatar johnSamilin commented on June 15, 2024

Hey @johnSamilin, thanks!

The implementation of hide behaviour is pretty simple:

// targetPosition is the position of the closest obstacle
return vectorPool.get().copy(hideableEntityPosition).sub(targetPosition).normalize().multiplyScalar(distanceAwayFromHideable).add(hideableEntityPosition);

So I'm not sure how this formula would work for multiple entities given its simplicity. Would we hide from the center point of each hide targets? We could alternatively draw an imaginary line from each hide target to the closest obstacle and find a point inside the imaginary area limited by these imaginary lines behind the obstacle however that seems geometrically more complex to implement.

I'd suggest you start simple first:

  • Create a dummy entity
  • Set this entity as the hide target
  • For each frame calculate the center point of each of your actual hide targets
  • dummyEntity.setPosition(centerPointYouCalculatedAbove)

so the hide behaviour would hide from the center point. Let's see if that works. If it does not, then I'd also consider implementing some sort of intelligence to my entity and just dynamically modify the hide target on the run based on some criteria (could be distance, whether it can be seen or not etc.).

What do you think about adding two methods to Steerable, addHideTargetEntity and removeHideTargetEntity? setHideTargetEntity should remain same and forcibly set hide target to the one passed in parameters?

from kompute.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.