Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15910

How to rotate a group baced on camaras orientation?

$
0
0

I am making a game where you have a sword that you can swing, the sword is in a group with an offset so it is positioned right. I am trying to make it so that when I press Z the sword swings down and then back up via rotation. how do I get the sword to swing in the direction I face? Currently, I have if (keys.z) group.rotation.x -= Math.PI/100;, but that only works for the x-axis. The model copes the camera position with group.position.copy(camera.position);, and quaternion with if(!keys.z)group.quaternion.copy(camera.quaternion);.One way I thought do do it was to change the sword's rotation offset but I don't know how to do that, would that even work? Anyways please help I love coding and want to make this game!


Viewing all articles
Browse latest Browse all 15910


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>