- Home /
Rotate From SpawnPoint TO Transform Rotation
Hello Everyone
i Got Problem With Shooting Bullet
its shoot from the spawnPoint [Weapon] To Forward
i actually need it to shoot from SpawnPoint To Forward but with rotate
Lemme Show You This Photo, Might Explain Better
 //So In Instantiate i use
 SpawnPoint.rotation
 
 //i should changed it and make to go to the center
 

Answer by robertbu · Apr 26, 2013 at 05:59 PM
As with any mouse position, you have to convert the 2D coordinate into one in 3D space by specifying a Z distance in front of the camera for the point, but works the same way no matter where the camera faces:
 function Update() {
     var v3 = Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane);
     v3 = Camera.main.ScreenToWorldPoint(v3);
     Debug.DrawLine(transform.position, v3, Color.green);
 }
sry i guess question totally changed :)
ur Code Helpfull! +1
Yes, the question totally changed. The angle you rotate the bullet to will vary depending on how far in front of the ray your hit point is. Assu$$anonymous$$g you have a ray up from "$$anonymous$$e", typically the code would work something like this (untested):
 RaycasyHit hit;
 Vector3 v3HitPoint;
 
 if (Physics.Raycast(ray, out hit) {
    v3HitPoint = hit.point;
 }
 else
   v3HitPoint = ray.GetPoint(defaultDistance);
 
 GameObject go = Instantiate(goPrefab, transform.position, Quaternion.identity) as GameObject;
 go.transform.LookAt(v3HitPoint);
 go.Rigidbody.AddForce(go.transform.forward * 2000);
umm,, we cant just do the CrossHair then i will make the bullet at crosshair Transform Forward
Your answer
 
 
             Follow this Question
Related Questions
Steam Vr and Camera Target Textures 0 Answers
Weapon Camera FOV 1 Answer
My Camera won't activate trough script 1 Answer
How to fade in/out the view of a specific Camera? 2 Answers
TopDown shooter camera 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                