created player model, added rotation with movement, better lighting and camera positioning
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -320,6 +320,7 @@ version = "0.17.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76d3ee8652fe0577fd8a99054e147740850140d530be8e044a9be4e23a3e8a24"
|
||||
dependencies = [
|
||||
"bevy_dylib",
|
||||
"bevy_internal",
|
||||
]
|
||||
|
||||
@@ -604,6 +605,15 @@ dependencies = [
|
||||
"sysinfo",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_dylib"
|
||||
version = "0.17.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d50a92aea6e896b6939ea51db6ced3a7e2dfd591016286e3eed9cb60d9e4f149"
|
||||
dependencies = [
|
||||
"bevy_internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_ecs"
|
||||
version = "0.17.3"
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.17.3"
|
||||
bevy = { version = "0.17.3", features = ["default", "dynamic_linking"] }
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
|
||||
BIN
assets/models/employee.glb
Normal file
BIN
assets/models/employee.glb
Normal file
Binary file not shown.
BIN
modelling/employee.blend
Normal file
BIN
modelling/employee.blend
Normal file
Binary file not shown.
BIN
modelling/employee.blend1
Normal file
BIN
modelling/employee.blend1
Normal file
Binary file not shown.
43
src/main.rs
43
src/main.rs
@@ -23,36 +23,58 @@ fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
asset_server: Res<AssetServer>,
|
||||
) {
|
||||
// Camera
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
Transform::from_xyz(10.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
Transform::from_xyz(0.0, 25.0, -25.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
));
|
||||
|
||||
// Cube
|
||||
// Player
|
||||
commands.spawn((
|
||||
Mesh3d(meshes.add(Cuboid::new(2.0, 2.0, 2.0))),
|
||||
MeshMaterial3d(materials.add(Color::srgb(1.0, 0.0, 0.0))),
|
||||
Transform::from_xyz(0.0, 1.0, 0.0),
|
||||
SceneRoot(asset_server.load("models/employee.glb#Scene0")),
|
||||
//MeshMaterial3d(materials.add(Color::srgb(0.9, 0.83, 0.6))),
|
||||
Transform::from_xyz(0.0, 1.5, 0.0).with_scale(Vec3::splat(0.5)),
|
||||
Player {
|
||||
move_speed: 10.0,
|
||||
height_offset: 1.0,
|
||||
height_offset: 1.5,
|
||||
},
|
||||
MoveTarget {
|
||||
position: Vec3::new(0.0, 0.0, 0.0),
|
||||
},
|
||||
));
|
||||
|
||||
// Light (DOESN'T WORK)
|
||||
// Light
|
||||
|
||||
commands.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 200.0, // Subtle fill light so shadows aren't pitch black
|
||||
..default()
|
||||
});
|
||||
|
||||
commands.spawn((
|
||||
DirectionalLight {
|
||||
illuminance: 1000.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
Transform::from_rotation(Quat::from_euler(
|
||||
EulerRot::XYZ,
|
||||
-0.8, // Pitch down (looking down at scene)
|
||||
0.5, // Yaw (angle from side)
|
||||
0.0, // Roll (no rotation)
|
||||
)),
|
||||
));
|
||||
|
||||
/*commands.spawn((
|
||||
PointLight {
|
||||
intensity: 1000000.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
Transform::from_xyz(0.0, 10.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
));
|
||||
Transform::from_xyz(0.0, 10.0, 0.0),
|
||||
));*/
|
||||
|
||||
// Plane
|
||||
commands.spawn((
|
||||
@@ -122,6 +144,9 @@ fn move_to_target(mut query: Query<(&mut Transform, &MoveTarget, &Player)>, time
|
||||
transform.translation = adjusted_target;
|
||||
} else {
|
||||
transform.translation += direction.normalize() * move_amount;
|
||||
|
||||
let target_look = target.position + Vec3::Y * player.height_offset;
|
||||
transform.look_at(target_look, Vec3::Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user