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 Er Muyayo Olivier · May 05, 2015 at 08:56 PM · a

Detect Collision when moving an object

Hi everyone! I'm doing some tests in Unity and last day I made an obstacle that can be movable with the mouse wheel. But when the player collides with in, the obstacle can be movable anyway. Here's a video

And here is the script that I use for move the obstacle with mouse wheel:

 #pragma strict
     var targetAngle = 0;
     var degreesPerClick = 2;
     var secsPerClick = 0.3;
    
     private var curAngle = 0f;
     private var startAngle=0f;
     private var startTime=0f;
     
     function OnMouseOver () {
         var clicks = Mathf.Round(Input.GetAxis("MouseWheel") * 100);
         if (clicks != 0) {
             targetAngle += clicks * degreesPerClick;
             startAngle = curAngle;
             startTime = Time.time;
                         }
                            
         var t = (Time.time - startTime) / secsPerClick;
         if (t <= 1) {
             curAngle = Mathf.Lerp(startAngle, targetAngle, t);
             transform.eulerAngles.z = curAngle;
         }
            
  
     }

Thanks and sorry for my bad English :P

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 Xarbrough · May 05, 2015 at 11:05 PM 0
Share

You're linked Youtube video is private, please make it public so others can view it. Only by reading your description, I'm unsure what your desired outcome is and what actually happens. Can you try to rephrase it more clearly?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by theBlueBisu · May 06, 2015 at 01:39 PM

Hello

(Your video link is private)

I'm not sure of what want...

Some problems appear with scripted move and collisions. Your object has he a Rigidbody, on kinematic mode?

If the question is "why the scripted object move (turn if I understand well)", is just because you force it.
In this case, I think about:

  • Look towards check if a player(or object) is OnCollision. You can heard OnCollisionEnter/OnCollisionExit to modify a bool variable and test it before turn.

  • Use a combo object( Rigidbody kinematic,YourScript ) + object( Rigidbody, FixedJoin (or look others), Collider ) and with some adjustments make the join not rigid... (but I imagine an effect of elastic replacement which can appear, that you can maybe delete with taking rotation of the joined object if mousewheel==0, to not force rotation before the player has move)

  • Else to test if you can move or not you can test with RayCast, but in your case of rotation... not obvious

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 Er Muyayo Olivier · May 06, 2015 at 02:20 PM 0
Share

Thanks for your answer. I'll try it. Sorry but it's difficult to explain it. Now you can see the video, sorry but I didn't saw that it was in private mode.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Update () cant be a coroutine 2 Answers

How to create multiple choice question with audio clip 0 Answers

Adding a solid mesh 1 Answer

How can i insert a package? 1 Answer

Input key Conversion Query? 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