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 Double-V · Aug 20, 2016 at 02:14 PM · rigidbodyinstantiate3dvelocityvariables

Multiplying something.forward using a variable doesn't actually multiply, but multiplying by a number does.

So I have an instanciation and I set the velocity of the object with this:

 plasma_instance.velocity = (shooting_origin.forward * bullspeed_plasma);

And the object does travel forward from the shooting_origin, but no matter how high the bullspeed_plasma (float) is, it still travels with the same speed.

But wait, there's more... When I multiply it by a number:

 plasma_instance.velocity = (shooting_origin.forward * 30);

or

 plasma_instance.velocity = (shooting_origin.forward * 400);

...then the velocity is different, as expected. So my question is how to multiply it by a variable?

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

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Jessespike · Aug 21, 2016 at 12:01 PM

If bullspeed_plasma is a public float then the value in the Inspector will overwrite any starting value you may have inside the script.

For example, you put this script on a GameObject.

 public class Test : MonoBehaviour {
 
     public float bullspeed_plasma = 1f;
 }

and then you decided to change the value in the script, say 100

     public float bullspeed_plasma = 100f;

The value will be 1f when you play the game, because 1f was the last value set in the inspector.

I'm only guessing this was the issue, I'm not really sure what's going on from the provided code. You can multiply a forward with a variable, so that's not the issue. Something else is going on. Try adding Debug.Log and see if anything sticks out

 print(bullspeed_plasma);
Comment
Add comment · Show 1 · 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 Double-V · Aug 21, 2016 at 07:34 PM 0
Share

Yup, that was the issue, I never look at variables in the inspector, but now I did and it had a value of 20, but I was also declaring it in the code. Thanks!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Calculate Angular Velocity to Match Remote Position 0 Answers

Move Ball With Same Velocity on Slope 1 Answer

Resume movement of instanced object relative to the original after instantiation. 2 Answers

Rotate Rigidbody Towards Velocity? [3d] 0 Answers

Velocity powered rigidbody on a moving platform without parenting. 3 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