Fixed firearm y_rot glitch. Now firing point is where it should be
This commit is contained in:
parent
a64e646e78
commit
47764f63a1
|
@ -15,8 +15,8 @@ impl Firearm {
|
|||
Firearm::M4A1 => {
|
||||
FirearmData {
|
||||
firing_point: FiringPoint {
|
||||
forward: 1.0,
|
||||
up: 1.0,
|
||||
forward: 0.0,
|
||||
up: 0.0,
|
||||
right: 0.0,
|
||||
},
|
||||
caliber: Caliber::NATO556,
|
||||
|
|
|
@ -59,27 +59,35 @@ fn spawn_firearm_on_player_hands(
|
|||
if let Some(gltf) = loaded_gltf_assets.get(&asset_handle.asset) {
|
||||
let firearm_data: FirearmData = firearm.firearm_data();
|
||||
let mut firearm_transform = Transform::from_xyz(0.0, 0.0, 0.0);
|
||||
firearm_transform.rotate_y(utils::rad_deg::radians_from_degrees(
|
||||
|
||||
firearm_transform.rotate_local_y(utils::rad_deg::radians_from_degrees(
|
||||
firearm.holdable_object_data().y_rot,
|
||||
));
|
||||
firearm_transform.scale = firearm_transform.scale * firearm_data.scale_factor;
|
||||
|
||||
let scene = gltf.scenes[0].clone();
|
||||
|
||||
let firearm_entity = commands
|
||||
.spawn((
|
||||
SceneBundle {
|
||||
let firearm_asset_entity = commands.spawn((SceneBundle {
|
||||
scene,
|
||||
visibility: Visibility::Inherited,
|
||||
transform: firearm_transform,
|
||||
..default()
|
||||
},
|
||||
}, Name::new("Firearm Gltf Asset"))).id();
|
||||
let firearm_entity = commands
|
||||
.spawn((
|
||||
firearm_data.clone(),
|
||||
firearm.holdable_object_data(),
|
||||
MagazineData { rounds_shot: 0, max_capacity: firearm_data.max_capacity },
|
||||
InPlayerHands,
|
||||
Name::new("Firearm")
|
||||
))
|
||||
Name::new("Firearm"),
|
||||
TransformBundle {
|
||||
local: Transform::from_xyz(0.0, 0.0, 0.0),
|
||||
..Default::default()
|
||||
},
|
||||
VisibilityBundle {
|
||||
visibility: Visibility::Inherited,
|
||||
..Default::default()
|
||||
}
|
||||
)).push_children(&[firearm_asset_entity])
|
||||
.id();
|
||||
|
||||
commands.entity(player_hands).push_children(&[firearm_entity]);
|
||||
|
|
Loading…
Reference in New Issue