-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add character #6
Conversation
ctrl.velocity = match ctrl.target { | ||
Some(target) => (target - transform.translation).normalize_or_zero() * ctrl.speed, | ||
None => Vec3::ZERO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
призрачный гонщик через стены без алгоритма
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Потом вместо этого будет навмеш и прочие ништяки. Мб реализация навмешей будет через https://github.com/TheGrimsey/oxidized_navigation, с меньшей вероятностью через https://github.com/vleue/bevy_pathmesh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кстати, поскольку все персонажи будут так или иначе использовать navmesh, то работы с коллизиями почти не будет (не уверен, нужна ли нам физика вообще).
pub fn move_character( | ||
time: Res<Time>, | ||
mut query: Query<(&mut CharacterController, &mut Transform), Without<Parent>>, | ||
) { | ||
for (mut ctrl, mut transform) in query.iter_mut() { | ||
ctrl.velocity = match ctrl.target { | ||
Some(target) => (target - transform.translation).normalize_or_zero() * ctrl.speed, | ||
None => Vec3::ZERO, | ||
}; | ||
transform.translation += ctrl.velocity * time.delta_seconds(); | ||
|
||
if ctrl.velocity.length() > 0.0 { | ||
// TODO: remove pitch/roll | ||
*transform = transform.looking_to(ctrl.velocity, Vec3::Y); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В идеальном случае нужно сократить количество вызовов и не делать всё это каждый кадр.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавь TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут всё максимально быстро работает, не вижу причин для оптимизаций. С другой стороны таргет можно хоть каждый кадр менять (например оный может двигаться).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В целом это всё лишь затычка для текущего уровня технологий. Но поверх этого уже можно делать AI например.
Добавил примитивную реализацию персонажей