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 /
avatar image
0
Question by Dryden Richardson · Aug 14, 2011 at 11:30 PM · javascriptprojectilenoob

Problem when creating a projectile for a weapon. (FIXED)

Hi I'm having a problem with a projectile for my First Person Character Controller, when I press the fire button it spawns but it is rotated facing a different direction instead of straight forward, does anyone know what is wrong?

Here's a Video of my problem. http://www.youtube.com/watch?v=g632TdDKuCw

Here's my code.

var projectile : Rigidbody; var speed = 10;

function Update() {

if( Input.GetButtonDown( "Fire1" ) ) {

audio.Play(); // Delay a clip by 1 sec (44100 samples) audio.Play(44100);

var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation ); instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) ); Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider ); } }

The rotation of the Bullet is Rotation X0 Y90 Z0 Y was originally 0 but I changed it, it still no improvement. Also could the problem be this? transform.rotation );

Can anyone help me? Fixed the problem, using different model.

Comment
Add comment · Show 5
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 FTheCloud · Aug 15, 2011 at 12:10 AM 1
Share

Tried the video but it says it's private

avatar image Uriel_96 · Aug 15, 2011 at 01:03 AM 0
Share

Dryden Richardson, when you have a problem like this is better to put your script ins$$anonymous$$d of a video, unless the problem is in physics or something like that.

avatar image HHameline · Aug 15, 2011 at 01:59 AM 0
Share

Like Uriel Said perhaps if you where to post the code where you create the projectile we would be able to help you a bit more. It sounds like you might have a problem in you Instantiate call though, obviously I'm not sure how your handling the projectiles but I found it works best if you make a prefab and instantiate it with the players rotation. You may also want to check the axises of the projectile to see if perhaps it is instantiating the proper way but you should be using the x ins$$anonymous$$d of z or vice versa. Hope that helps a little bit. If you post your code I'll be more help.

avatar image Dryden Richardson · Aug 15, 2011 at 02:21 PM 0
Share

Sorry, The Video is working now.

avatar image Joshua · Aug 15, 2011 at 02:27 PM 0
Share

We cannot help you if we don't see the code.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Joshua · Aug 15, 2011 at 02:18 AM

You're probably using Instantiate to spawn the projectile. The third parameter of this method is the rotation. Change to rotation to what you want it to be.. most likely the transform.forward of the character.

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 Dryden Richardson · Aug 15, 2011 at 02:39 PM 0
Share

Is this the rotation? transform.rotation );

avatar image Joshua · Aug 15, 2011 at 02:43 PM 0
Share

That's 'a' rotation. But I don't know how the axis are set up for your model. It could be that for 'forward axis' is pointing sideways.

avatar image Dryden Richardson · Aug 15, 2011 at 02:52 PM 0
Share

Okay here's the axis Rotation X0 Y90 Z0 The Y Axis was originally 0 aswell but I change it and there was still no improvement.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Cant get my gui in the quiwindow to load there functions... 1 Answer

Objects falling from the specific height randomly. 2 Answers

How do I make a projectile disappear seconds after it is fired? The projectile stays within the game forever. How do I disable it, 3 seconds after it has been fired? 1 Answer

Spawning random terrain pieces 1 Answer

How to display previous players scores as well as current player score at the end of the game? 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