Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Aug 14, 2014 at 04:47 PM by Lukamyte for the following reason:

Alternative option to guns (swords, a hack 'n' slash favorite!)

avatar image
0
Question by Lukamyte · Aug 14, 2014 at 03:07 PM · rotationinstantiatebullet

Instantiate rotation not working

Hi. My game has a part of a script i am using to instantiate bullets, but the rotation argument on the Instantiate is not working like I want it to.

 var y : float;
 
 function Update () {
     y = transform.eulerAngles.y;
     
     if(clicked){
         Instantiate(bullet, transform.position,Quaternion.EulerAngles(0, y, 0));
     }
 }

The bullet ends up shooting off into some random direction, anything but what I want. Thank you!

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 MrSteve1 · Aug 14, 2014 at 03:11 PM

exchange Quaternion.EulerAngles(0,y,0) for transform.rotation.

Hope this helps.

Comment
Add comment · Show 3 · 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 Lukamyte · Aug 14, 2014 at 03:12 PM 0
Share

i have already tried that, same result

avatar image MrSteve1 · Aug 14, 2014 at 03:16 PM 0
Share

I would perhaps reccommend spawning from an empty game object as an independent spawn point, then you wont have to rely on rotations. Try this`enter code here`

 var spawnPoint : Transform;
 
 function Update()
 {
     if(clicked)
     {
         Instantiate(bullet,spawnPoint.position,spawnPoint.rotation)
     }
 }


Hope this helps more.

avatar image MrSteve1 · Aug 14, 2014 at 03:17 PM 0
Share

Dont forget to child the spawnpoint close to the end of the barrel or cannon (whatever your using) but not touching it.

Follow this Question

Answers Answers and Comments

22 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

Related Questions

Gun Projectile Shooting In Wrong Direction (Javascript) 1 Answer

Modify the rotation of Instatiate prefab 1 Answer

Turret bullet rotation problem 1 Answer

Shoot an object and have it move based on rotation 1 Answer

How to rotate an Instantiated object? 1 Answer


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