mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Clamp NPCs to surface
This commit is contained in:
parent
558dd99fd3
commit
df63e41a23
@ -20,6 +20,7 @@ impl Rule for SimulateNpcs {
|
||||
{
|
||||
let body = npc.get_body();
|
||||
|
||||
// Move NPCs if they have a target
|
||||
if let Some((target, speed_factor)) = npc.target {
|
||||
npc.wpos += Vec3::from(
|
||||
(target.xy() - npc.wpos.xy())
|
||||
@ -29,6 +30,11 @@ impl Rule for SimulateNpcs {
|
||||
* speed_factor,
|
||||
) * ctx.event.dt;
|
||||
}
|
||||
|
||||
// Make sure NPCs remain on the surface
|
||||
npc.wpos.z = ctx.world.sim()
|
||||
.get_alt_approx(npc.wpos.xy().map(|e| e as i32))
|
||||
.unwrap_or(0.0);
|
||||
}
|
||||
|
||||
// Do some thinking. TODO: Not here!
|
||||
|
Loading…
Reference in New Issue
Block a user