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
0
Question by Angelo_Burton · Dec 24, 2013 at 12:06 PM · physicsbounce

Character bounces after changing position

/e 2: The bouncing apparently was caused by overlapping materials/shapes even though they were completely flat and the same height. Thanks to the snapping tool I got rid of the overlaps and now the ball rolls smooth!

Hello :)

I'm currently expanding a little on the Tutorial 1, in which you create a rolling ball game. I've created a "Teleporter". When the ball enters a Trigger zone, the ball's position on the Z plane gets changed. The Ball's X, Y position and rotation all remain unchanged.

After the ball's position gets adjusted via this "Teleporter" he 7 out of 10 times bounces off the ground after continuing to roll a short while or starts to bounce immediately after the position change and I can't figure out why he randomly starts bouncing.

The Y plane is level, it's a flat surface and the same height at both positions.

Any ideas why the bouncing occurs? I have tried minimally adjusting the Y position because I thought perhaps the problem has something to do with friction but no luck with that approach either.

/e: perhaps I should mention that I use the standard gravity, friction etc. settings and the ball enters the "teleporter" usually at a "medium" speed. The ground has no physics material applied to it.

Here's the relevant code if that helps:

 else if (other.gameObject.name == "TeleportSouth"){
 TeleportToPosition1 ();}
 
 void TeleportToPosition1 (){
 float currentpositionx = gameObject.transform.position.x;
 float currentpositiony = gameObject.transform.position.y;
 Vector3 teleportPosition1 = new Vector3 (currentpositionx, currentpositiony, -50.0f);
 rigidbody.position = (teleportPosition1);
 rigidbody.rotation = (Quaternion.identity);}
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 felixpk · Dec 24, 2013 at 12:28 PM

 void OnTriggerEnter(Collider other){
   if(other.gameObject.tag.Equals("TeleportSouth")){
     TeleportToPosition1();
   }
 }
 
 
 void TeleportToPosition1(){
   float currPosX = transform.position.x;
   float currPosY = transform.posdition.y;
 
   Vector3 telePos1 = new Vector3(currPosX,currPosY-0.5f, -50f);
 
   transform.position = telePos1;
 }

This is untested and just slightly adjusted, maybe it works like this. It's a good thing to use Tags instead of Names.

This script requieres to be on the Ball, I don't know where the Script is attached to.

If you don't want the Ball to just pop out on the other Position, you could also use

 transform.position = Vector3.Lerp(transform.position,telePos1,5f);

I hope that helps a little bit.

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 Angelo_Burton · Dec 24, 2013 at 02:48 PM 0
Share

Thanks for the quick reply :) I thought you needed a Quaternion as well for some reason, works without just fine to my surprise.

$$anonymous$$ay I ask why it's better to use tags ins$$anonymous$$d of names? Performance reasons or just convenience? I want to avoid - if possible - having a very long list with tags of which some might be even only used once for unique stuff like this teleporters (different teleporter = different target co-ordinates).

The bouncing apparently was caused by overlapping materials/shapes even though they were completely flat and the same height. Thanks to the snapping tool I got rid of the overlaps and now the ball rolls smooth!

$$anonymous$$erry X-$$anonymous$$as everyone!

avatar image felixpk · Dec 24, 2013 at 02:59 PM 0
Share

Honestly I have no clue, but that was something else posted to me. But I think it is convenience.

Ins$$anonymous$$d of having lot of different Teleport tags you could use just one "Teleporter" tag, every teleporter gets that tag. I don't know how the destination of each Teleporter changes but if it's everytime -50 Units backwards, that would be a solution.

Else you could check where the teleporter is, and then decide where to teleport the ball. But that would do nothing special to your game. Just saying.

$$anonymous$$erry X-$$anonymous$$as too :)

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

19 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

Related Questions

how to change physics material of a colider in runtime 5 Answers

Is there anyway to "speed up" physics? 1 Answer

How to make objects "Bounceable" 1 Answer

How to get a perfect bouncing ball. 6 Answers

Swipe Wind 2 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