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 MichaelHarris95 · Sep 18, 2014 at 02:37 PM · physicsinput

Im having a Problem with Basic Collision.

Hello! Im trying to make an basic controller. Im using 2D objects in the 3D plane. The issue that I have been having is that I cant get my objects to collide with a basic Box Collider. I have tried everything from using OnTriggerEnter/OnTriggerStay/OnCollisionEnter/....etc but have had no success. However whenever I use CharacterMotor the objects collide and stop.

What I need is a script that when the object hits a box collider it stops and doesnt keep going.

The Script I have been using for Movement

var speed = 5;

var player : Transform;

 function Update () 
 {
 
 
 
  if (Input.GetKey(KeyCode.W)) {
      var PositiveForward : float = Time.deltaTime * 10;
      transform.Translate(0 , 0, PositiveForward);
      
     transform.eulerAngles.x = 0;
     transform.eulerAngles.y = 0;
     transform.eulerAngles.z = 0;
     
     
     }
      
  if (Input.GetKey(KeyCode.D)) {
      var PositiveZ : float = Time.deltaTime * 10;
      transform.Translate(0 , 0, PositiveZ);
      transform.eulerAngles.x = 0;
     transform.eulerAngles.y = 90;
     transform.eulerAngles.z = 0;
 }
 
 
 
 if (Input.GetKey(KeyCode.S)){
      var Backward : float = Time.deltaTime * 10;
      transform.Translate(0 ,0 , Backward);
     transform.eulerAngles.x = 0;
     transform.eulerAngles.y = -180;
     transform.eulerAngles.z = 0;
 
 }
 
 if (Input.GetKey(KeyCode.A)){
      var Left : float = Time.deltaTime * 10;
      transform.Translate(0 , 0, Left );
      transform.eulerAngles.y = -90;
 }
 
 
 }
 

Im honestly lost im not the best when it comes to coding.

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

Answer by zeeshandar · Sep 18, 2014 at 02:50 PM

if you are using box collider 2D you should try OnCollisionEnter2D(Collider2D collider) or OnTriggerEnter2D(Collider2D collider) and put debu.log("") in it to check which one is firing and also make sure your direction is not along z-axis..

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 MichaelHarris95 · Sep 18, 2014 at 04:52 PM 0
Share

Im getting collision with the 3D collider. Im using charactercontroller on my player. I used Debug.Log "Hit" and it registers the collision but it just doesnt stop the object.

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do I make a first person player get in a vehicle? 0 Answers

(C#) A better way to limit actions to once per button press? 2 Answers

ConfigurableJoint Anchors and nested RigidBodies 2 Answers

Can you access non-standard mouse buttons? 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