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 /
avatar image
1
Question by rodimus_strom · Oct 27, 2012 at 05:17 AM · bounce

Bounce with speed

hey i write a bounce code

`#pragma strict

private var DirectionX:int;

private var YFactor:float;

private var XFactor:float;

function Start ()

{

         YFactor = 9;

         XFactor = 0.6f * DirectionX;                     //DirectionX =-1/1

}

function FixedUpdate()

{

}

function Update ()

{

}

function OnCollisionEnter(collisionInfo:Collision)

{

 if(collisionInfo.transform.tag == "Base")

 {

     this.rigidbody.AddForce(Vector3.up*YFactor,ForceMode.Impulse);

     this.rigidbody.AddForce(Vector3.right*XFactor,ForceMode.VelocityChange);

 }

 else if(collisionInfo.transform.tag == "Wall")

 {

     XFactor *= -1;

     this.rigidbody.AddForce(Vector3.right*XFactor*2,ForceMode.VelocityChange);

 }

}` now if i attach this script to an object that will start bounce(without bounce material) but with a constant speed. so my question is if i need that one ball bounce faster than the other one i have to set a speed for it but don't understand where,changing in "YFactor" will only increase its height of bounce .plz any solution .

Comment
Add comment · Show 1
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 Fattie · Oct 27, 2012 at 09:21 AM 0
Share

suggest unityGE$$anonymous$$S.com for basic tutorials

the physics engine in Unity will do all the bouncing for you. you do nothing.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Wiki

Answer by nullkraft · Oct 29, 2012 at 02:00 AM

You need to set an initial velocity. It's not pretty but it works.

This gives you a control that will let you set the x, y and z components. For example, to set the initial velocity for gravity you would set the y component to -10. Most other velocities would be set with a positive value in the proper direction.

public var initialVelocity : Vector3;

     function Start() {
             transform.ridigbody.velocity = initialVelocity;
     }

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 rodimus_strom · Nov 01, 2012 at 02:13 PM 0
Share

Thanks for reply but its not working,is there anyway that I can change the time scale for particular one object in scene.

avatar image Fattie · Nov 01, 2012 at 02:20 PM 0
Share

yes, it's very simple. just use the CONSTANT FORCE component.

one click. find "constant force" in the menu of Unity

never, ever change gravity for any reason

just go to unityGE$$anonymous$$S.com for a full intro

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

11 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

Related Questions

How do you keep a bouncing ball from "breaking" through cloth 1 Answer

Help me bounce (make player bounce when landing from a jump) 0 Answers

pong question 2 Answers

Vector3.Reflect - object bounce 1 Answer

How to reduce bounce? 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