splash27 Posted June 5, 2018 Share Posted June 5, 2018 In a shooter game I can calculate the vector with direction that player look at. This vector can be used to guide the bullet. But in this case the weapon will have 100% accuracy. I want to add a random angle (within limited range) to this vector to simulate accuracy less than 100%. So, the question is how to get rotated vector in 3D space? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 5, 2018 Share Posted June 5, 2018 hi use MAth : (Math.random()*1.-0.5)*0.1 https://www.babylonjs-playground.com/#2GXKNW#32 var pos = camera.position; var tar = { x:camera.getTarget().x*1.+(Math.random()*1.-0.5)*0.1-pos.x, y:camera.getTarget().y*1.+(Math.random()*1.-0.5)*0.1-pos.y, z:camera.getTarget().z*1.-pos.z}; var r = new BABYLON.Ray( pos,tar,1000.); var meshFound = scene.pickWithRay(r ); V!nc3r 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.