I want throw ball by local position, but it's using global position
Hello, sorry for bad english, but I hope it's enough understandable. I have this script:
using System.Collections;
using UnityEngine;
public class Shoot : MonoBehaviour {
public GameObject BulletPrefab;
public float shotPower = 500f;
public Transform StartPoint;
void OnMouseDown() //
{
GameObject obj = Instantiate(this.BulletPrefab, this.StartPoint.position, Quaternion.identity) as GameObject;
obj.transform.forward = this.StartPoint.forward;
obj.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * this.shotPower);
}
}
my "bulletPrefab" is flying in forward of global position, but I want that's was flying in forward of local position. I use this script from youtube, him script is working fine(How I can saw on video), but on my PC it's wrong. I Installed Unity yesterday, so I am beginer...
Comment
Your answer
Follow this Question
Related Questions
Super beginner question on raycast 0 Answers
Microsoft VisualStudio not showing quickcode/tooltips for unity. 0 Answers
if with two conditions not working 1 Answer
AnimationComplete() Error 0 Answers
I need help with my scripts! 1 Answer