• 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
Question by Lene · Nov 28, 2010 at 12:51 AM · collisioncolliderwallgetkeystopped

Colliders and GetKey

Hi everybody

I have an object controlled by player (controls with arrow keys, script already done, p.o. moves on the x/z axis for 0.5. With a counter I managed to make it move while button is down, but only 5 times per step, so it's as fast as I wish it to be) That "player object" is moved around in a closed room (plane, 4 walls) In that room there are several cubes.

What I want to do 1:

Moving the player object around in the room. It should be stopped by the walls. Walls and p.o. have box colliders, p.o. has a rigidbody with gravitation and stop rotation enabled.

Problem 1: When p.o. hits a wall, it doesn't just stop moving, it's pushed backwards by the wall and it moves backwards slowly.

Question: How can I make the p.o. just being stopped by the wall without any other movement? (wall as an obstacle)

What I want to do 2:

When p.o. collides with a cube in the room, it should be stopped (same as in point 1) BUT: When it is stopped by the cube, and player pushes the space key, the cube should be pushed in the opposite direction from the player object, and it sould move until it is stopped by a wall or another cube. But it can't be stopped by the player.

(for those of you who played zelda: twilight princess, my idea is to create a game that's like the part in the ice-land where you push arund ice-cubes until one of them stays on a certain position (= key on the ground) which opens a door or triggers another action)

problem 2:

The pushing is only possible when the p.o. is touching the cube. So I guess I need an enter collision function and then write if(Input.GetKey("space") --> transform position blahblah...but I don't now how exactly...

I'm new at scripting and I want to keep it as easy as possible... ;)

Greez

L.

Comment

People who like this

0 Show 0
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Stop Dashing through walls 1 Answer

Quickly spinning player glitches through walls 2 Answers

Why is my AI not thinking the collisions fast enough? 1 Answer

making bullets disappear when they collide 3 Answers

Can mesh colliders be used for buildings? 1 Answer


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