Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 30, 2016 at 12:11 AM by Le-Pampelmuse for the following reason:

Duplicate Question:

https://www.google.com/?gws_rd=ssl#safe=off&q=unity+bullet+prefab+faces+wrong+way

avatar image
-1
Question by Zitoox · May 12, 2016 at 04:14 PM · scripting problemspawning problems

FPS Bullet spawn problem

alt textHi! My FPS is almost done, but i have a little problem that i wasn't able to solve. When i shoot with my gun, the bullet prefab spawn in the wrong direction, like in the image that i uploaded. No matter if i i change the direction of the prefab, when it spawns, it is in the wrong direction, making the bullet look like ridiculous! What i need to do so the bullet spawns in the right angle?

Here's my shooting script:

using UnityEngine; using System.Collections;

public class ShootDemo : MonoBehaviour { public Rigidbody projectile; public float speed = 0;

 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         Rigidbody instantiatedProjectile = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
         instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0, 0, speed));
     }
 }

}

pf.png (320.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

Answer by Tyche10 · May 12, 2016 at 05:26 PM

I think you can find the answer in this unity tutorial: http://unity3d.com/learn/tutorials/modules/beginner/scripting/instantiate. Add an empty gameobject with the right position and rotation, drag it into a public Transform variable in your script and use its transform position and rotation in the instantiate function.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cherno · May 12, 2016 at 05:28 PM 0
Share

It's also possible to set the rotation after instantiating.

avatar image Zitoox · May 12, 2016 at 10:27 PM 0
Share

Yeah i know! SpawnPoint empty game object! I already have done this. SpawnPoint is the bullet spawner and there's only one side i can rotate it so it shoot the bullet correctly, but if i do this the bullet will spawn in an reverse way (it will go back) and i can't just rotate the map!

Follow this Question

Answers Answers and Comments

50 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

My character spawns in spawn point then instantly teleports to random location over and over again. 1 Answer

Help with object spawning bug 0 Answers

Hello Friends, When I am trying to shoot, my bullet only goes on one side. Even I turn my Player my bullet doesn't turn, it's only move on one direction. I dont know What to do? Please help Me? 0 Answers

Problems with instantiate 0 Answers

Instantiate not working? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges