Question by
Jacobsc · Aug 29, 2020 at 10:55 PM ·
c#instantiatescripting beginnerfunctionpublic variable
Trying to give instantiated object a value
So I want to instantiate an object (bullet) that will blow up at where it was clicked (flak cannon).
This is what I use for Instantiate
Instantiate(bulletPrefab, firePointOne.position, firePointOne.rotation)
This is a function for getting mouse position (located in update)
//mouse position to trigger bullet
Vector3 mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
and inside the bullet's script would be this variable that needs to receive the value
public Vector3 blowCation;
Then I just need to have it blow up on that position, but I can do that myself, I just need to get the position for the bullet.
Comment