Closed Fy-Spot closed 1 year ago
here what will explain the code better
set_onkey_controls(){ const{rh,lh,rl,ll,hd,body,left_hand_pivot,right_hand_pivot,right_leg_pivot,left_leg_pivot,playcam} = this const{golemMesh,Golem,hitbox,hitboxbody} = this
let cubeshape = new CANNON.Box( new CANNON.Vec3( 1, 1, 1 ) );
let clock = new THREE.Clock();
let delta = clock.getDelta();
let axisY = new CANNON.Vec3( 0, 1, 0 );
let rotationQuaternion = new CANNON.Quaternion();
let rotateAngle = Math.PI / 3;
let angleY = 0
hitboxbody.addShape( cubeshape )
Hello Guys, my name is Banjo OLuwafiayokunola, I am 14 and new to Cannon.js I am trying to give onkey controls for my player(golem) in my game but the change of quaternion has been a big problem for me I look around the internet and i am now stuck and how can i put a debounce to my jumpscript please. Thank you
here is the code
function executeMovement() { if(keyMap[37] === true){ //rotate left angleY -= 0.002; rotationQuaternion.setFromEuler(new CANNON.Vec3(0,1,0), angleY); let quaternion = rotationQuaternion.mult(hitboxbody.quaternion); quaternion.normalize(); } if(keyMap[39] === true){ //rotate right rotationQuaternion.setFromAxisAngle( axisY, -rotateAngle ); hitboxbody.quaternion = rotationQuaternion.mult(hitboxbody.quaternion) } if(keyMap[38] === true){ //move front function walk(time) { time*=0.005 left_leg_pivot.rotation.x = (Math.sin(time))/2 right_hand_pivot.rotation.x = (Math.cos(90+time))/3 right_leg_pivot.rotation.x = (Math.cos(90+time))/3 left_hand_pivot.rotation.x = (Math.sin(time))/2