Hello, I have been struggling for days trying to solve this with a lot of different methods with no luck.
I have a gun script that takes a Transform[] FirePoint;
and uses that transform to instantiate and rotate bullets. My problem is that my character uses Scale X to flip left and right so when he is facing Right all the bullets instantiate in the right direction but when he is facing left bullets go backwards. see gif:
I’ve put an example of my weapon script below to show how I am instantiating bullets. I’ve tried a lot of things like getting the facing direction of my character with transform.root but everything just kept making the script super cluttered and hacky.
void Update() {
float ShootControlThrow = CrossPlatformInputManager.GetAxis("Right Trigger");
if (ShootControlThrow > 0f) {
foreach (var position in FirePoint) {
var projectileBody = Instantiate(projectilePrefab, position.position, transform.rotation);
projectileBody.velocity = position.right * projectileSpeed;
}
}
}
void OnDrawGizmos() {
Gizmos.color = Color.red;
foreach (var position in FirePoint) {
Gizmos.DrawRay(position.position, position.right);
}
}
}
If someone has an idea of how I can change this line to make the Y of the FirePoint to 180 or something I would greatly appreciate it. This has been stumping me for many days.
var projectileBody = Instantiate(projectilePrefab, position.position, transform.rotation);