Hello i use this code to spawn cubes but they spawn next to the cube i attached the rigidbody so i want they to spawn on mouse position :
using UnityEngine;
using System.Collections;
public class IfClose : MonoBehaviour {
public bool Gravitronned;
public Rigidbody projectile;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RaycastHit hit;
if (Input.GetKeyDown (KeyCode.F)){
Rigidbody clone;
clone = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
clone.velocity = transform.TransformDirection(Vector3.forward * 10);
}
}
}