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 Braindrain85 · Jan 02, 2012 at 07:40 PM · collisionmovementcharactercontrols

Character doesen't collide

Heyhey... I am currently trying to make a platformer in unity. I started writing code for the Character but it won't collide with anything, though the character and the surroundings have collider components attached. The following code is for the Character...

 private var CharMovement = Vector3.zero; 

public var speed = 2;

function Update () {

 Movement();

 //Actually move Character
 transform.Translate(CharMovement * Time.deltaTime);

}

function Movement ()

{

 if(Input.GetButton("Right"))
 {    
     CharMovement.x = -1 * speed;
 }
 
 else if(Input.GetButton("Left"))
 {    
     CharMovement.x = 1 * speed;
 }
 
 else
     CharMovement.x = 0;

}

Sry I am new to unity... please help

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by dannyskim · Jan 02, 2012 at 08:03 PM

Does your character have a rigidbody attached to it? If it doesn't, I would suggest you add this and set it to isKinematic since you are moving the character by means of Translation and not adding physics forces to it.

A game object with a collider but without a rigidbody is considered a static collider, and typically should not be moved in a scene:

These are GameObjects that do not have a Rigidbody attached, but do have a Collider attached. These objects should remain still, or move very little. These work great for your environment geometry. They will not move if a Rigidbody collides with them.

The collision system is best used in conjunction with rigid bodies and physics. If you want you can try and switch to Triggers instead which may be a little bit more reliable if you do not plan on using rigid bodies.

http://unity3d.com/support/documentation/Components/class-BoxCollider.html

Comment
Add comment · 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
0

Answer by corpius4 · Jan 02, 2012 at 08:04 PM

if you are using java script, it is:

 CharMovement.x -= 1 * speed;//right
 CharMovement.x += 1 * speed;//left

since you didn't put"+=/-=" and put a "=", the command might have interfered with the regular physics

Comment
Add comment · 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
0

Answer by Braindrain85 · Jan 03, 2012 at 12:16 AM

Thank you for the fast answers. I tried both approaches and still the Charakter-Dummy slides through the ground plane. When I turn "is kinematic" off in the rigidbody, the Dummy behaves correctly and collides with the floor.... very weird... Here is a Picture of my Problem

http://imageshack.us/photo/my-images/31/collprob00.jpg/

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 GameFreak · Jan 03, 2012 at 10:57 AM 0
Share

It isnt that clear. Do you mean collision with the grass? That because unity terrain (Like whatever you make on the terrain trees grass etc) do not have colliders :). And if you do not want it to slide just increase the drag?

avatar image Braindrain85 · Jan 03, 2012 at 12:16 PM 0
Share

No, the grass has no colliders... only the plane beneath it. And I dont worry about the sliding. It is just that I want the capsule "walk" on top of that plane without intersecting...

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make characters go through each other 1 Answer

When walking, my character will not change sprites. 0 Answers

How to Make Characters Stick to Walls? 2D (c#) 2 Answers

Kinect issue with Character Movement while in flight 0 Answers

2D Movement [HELP!] 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