- Home /
How do i change my ships bullet starting point.???
I want the bullet to start shooting at a certian X/Y position, but no matter how i adjust them they always start a inside my ship and shoot out. I want the bullet to appear infront of my ship when i press the shoot button. THIS IS A 2D GRADIUS STYLE GAME IF THAT HELPS! Sorry if im a bit vague... I'm new...
Answer by Spider_newgent · Aug 02, 2016 at 06:51 PM
It'd be helpful to show your code so I can provide a specific example, but you need something like this:
public Vector3 firingPointOffset = new Vector3 ( 0, 1, 0); //whatever you want the offset to be.
Instantiate(bulletPrefab, Player.transform.position + firingPointOffset, Quaternion.identity);
Hope that helps.
Cheers
Dan
Answer by Hanoble · Aug 02, 2016 at 07:05 PM
Along with Spider's example with an offset, you could also create an empty GameObject called "firingPoint", and move that wherever you want the bullets to be instantiated from. At that point, you just need a reference to that firing point and when you instantiate the bullet object, do something like this:
Instantiate(bulletPrefab, firingPoint.transform.position, Quaternion.identity);
Your answer
Follow this Question
Related Questions
Precise vertex positions 1 Answer
Camera rotation around player while following. 6 Answers
How to get TouchPosition ?? 1 Answer
Furthest point of object in center of another object 0 Answers
Best way to find triangle that a given point occupies. 1 Answer