Skip to content

How can I change Agent.pos ? #5

Locked Answered by Nebukam
Nebukam asked this question in Q&A
Discussion options

You must be logged in to vote

The easiest way to go about that would be something along the lines of:

  1. Runs every frame:
// Given two agents, A will move toward B
agentA, agentB (enemy)

// AgentB being a moving goal, make sure AgentA prefVelocity is always pointing toward it
agentA.prefVelocity = (normalized direction from agentA to agentB) * movement speed

// Only run the simulation after that, ensuring agents have the most up-to-date 'intentions'
simulation.Run(Time.deltaTime); // Run instead of Schedule
  1. Runs once/when needed, but make sure it's applied before running a new simulation step
// Teleport agentA at a desired location
agentA.pos = teleport location

In that scenario, since agentA prefVelocity is kept…

Replies: 1 comment 7 replies

Comment options

Nebukam
Aug 2, 2023
Maintainer Author

You must be logged in to vote
7 replies
@chasing2moro
Comment options

@Nebukam
Comment options

Nebukam Aug 2, 2023
Maintainer Author

@chasing2moro
Comment options

@Nebukam
Comment options

Nebukam Aug 2, 2023
Maintainer Author

Answer selected by Nebukam
@chasing2moro
Comment options

@chasing2moro
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants