Question by
YoloJoe · Feb 08, 2016 at 09:09 PM ·
directionprojectile
How can I make a projectile shoot from the middle of the screen??
Hi. I have tried several different things, but nothing seems to work. Here is the current code:
if (_energyBar.valueCurrent >= 99) {
if (Input.GetButtonUp ("Special")) {
Debug.Log ("Energy Shot fired!");
_energyBar.valueCurrent = 0;
Rigidbody instantiatedProjectile = Instantiate (projectile, transform.position, transform.rotation) as Rigidbody;
instantiatedProjectile.velocity = transform.TransformDirection (new Vector3 (2, 2, speed));
}
This is what I use for Raycast: _ray = cam.ScreenPointToRay (new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0f));
And
RaycastHit hit; if (_playerController.aim) { if (Physics.Raycast (_ray, out hit, 100f)) { Instantiate (bulletHole, hit.point, Quaternion.FromToRotation (Vector3.up, hit.normal)); }
Comment
Your answer
Follow this Question
Related Questions
Having projectile face mouse position 1 Answer
predict line for a projectile 0 Answers
Projectile Direction issue - Sentry Turret - Autoaim 0 Answers
How to make the projectile move -45 0 Answers
How can I control my game object? 0 Answers