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 Wedny · Mar 25, 2013 at 05:35 AM · collisioncollidercontrollerkinematicphysical

how to stop colliders in a collision while using kinematic ways instead of physical ways?

Hello everyone! Here I have 3 items, a CharacterController, a Box and a Wall. I let the Controller to hit the Box making it move away using kinematic ways (e.g. directly editing its Transform.position).


But now I have a problem that if the Box hits the Wall after its being hit by the Controller and moving away, it will stay for a while and then rebound away because it can't pass through the Wall.


I know it's natural to stop the Box if I use physical ways in the Box's moving instead of using kinematic ways. So my quesion is how to stop the Box in the collision while using kinematic ways instead of physical ways?

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 Benproductions1 · Mar 25, 2013 at 06:13 AM 0
Share

To do it properly you would have to write your own physics system to calculate what would happen if the velocity was applied the way it should be, then apply the result to your cube. Why not just do it "the physical way" in the first place?

avatar image Wedny · Mar 25, 2013 at 10:18 AM 0
Share

because I want the Box to move a certain distance. If I apply the "physical way" in the first place, can u tell me how to make the Box move a certain distance?

avatar image sdgd · Mar 25, 2013 at 10:49 AM 0
Share

well I would do it on trigger enter

collider other kinematic = true; it'll stop exactly at that point and become kinematic

if you need code to be provided tell me

avatar image Wedny · Mar 25, 2013 at 11:11 AM 0
Share

@Fattie yeah, i tried ur method but the Box didn't stop while reaching the destination. $$anonymous$$y code is as follow


 #pragma strict
 
 static var controller : CharacterController;
 static var cube : Collider;
 static var flag : boolean = false;
 static var dir : Vector3;
 static var destination : Vector3;
 
 function FixedUpdate () {
     if(flag == true)
     {
 
            cube.rigidbody.AddForce(dir);
            print(cube.transform.position);
 
            print(destination);
         if(cube.transform.position == destination)
         {
             print("true");
             flag = false;
             dir = Vector3.zero;
             destination = Vector3.zero;
             cube.rigidbody.velocity = Vector3.zero;
         }
     }
 }



As above, I print the Box's position to see where it is. However it didn't enter the inner "if" code-block when the cube.transform.position is clearly equal to the destination

avatar image Wedny · Mar 25, 2013 at 11:12 AM 0
Share

@sdgd sure, post ur code and let's discuss it.

1 Reply

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

Answer by sdgd · Mar 25, 2013 at 11:56 AM

this is how I'd do it and as soon as object with tag: "you wanna strict to this tag" and will come in by force will stop.

kinematic never listens to forces

if it's anything else that's dragging you need to catch it inside with get component and disable that script and let me know if you need that too

 using UnityEngine;
 using System.Collections;
 
 public class NewBehaviourScript : MonoBehaviour {
     void OnTriggerEnter (Collider Other){
         Debug.Log("We're in");
         if (Other.tag == "you wanna strict to this tag"){
             Other.rigidbody.isKinematic = true;
         }
     }
 }

and OFC this has to be on a wall

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 sdgd · Mar 25, 2013 at 03:18 PM 0
Share

extend the collider for 0.5 more

ofc don't forget to accept the answer you are most satisfied for your question

do not forget this is not discussion it's Q/A

if you have sub questions you should open new question

you have FAQ on the right

and maybe your next question should be wider Question of what you want to achieve and provide more information and how you are handling the situation.

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

13 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

Related Questions

Can Kinematic Object collide with other Kinematic Object? 1 Answer

Make Character Controller a Box? 2 Answers

Quickly spinning player glitches through walls 2 Answers

Player Object can hang on the collider forever 0 Answers

Character controller collision 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