So I'm creating a direction vector by taking target.translation - spawn.translation. Spawning a tomato in the picture and setting it's direction, in my head this should result in the tomato eventually hitting It's target but I end up with a weird height-offset that I can not explain.
Is there something basic about the cordination-system I'm not getting or what's going on?
#Calculating direction vector and spawning entity results in strange height different.
4 messages · Page 1 of 1 (latest)
let target_translation = targets.get(target).unwrap().translation();
let direction = target_translation - tower_transform.translation();
Is the direction calculation.
And
commands.entity(tower_ent).with_children(|commands| {
commands
.spawn_bundle(SceneBundle {
scene: bullet_assets.bullet_scene.clone(),
transform: Transform::from_translation(
tower_transform.translation(),
),
..Default::default()
})
.insert(Bullet {
direction: direction,
speed: 2.5,
})
});
Is the spawn command.
You're adding the towers translation twice by spawning the tomato as a child
I've tried doing it without spawning as a child and created no difference in behaviour.