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 TerraQuartZ · Oct 03, 2012 at 01:46 PM · collisionmoveteleport

move an object instead of teleporting little bits

If i push the W button my char (a cube) uses this script to move forward:

 if (Input.GetKey(KeyCode.W))         
 {
 transform.position.z += 0.3;
 }

But then it teleports into objects in stead of pushing them. Does anyone know how to really move it instead of teleporting little bits? alt text

it looks like i dont have colliding at all on the Pic, but i have.. it just goes somethimes in other coins (the blue bar is the player controlled object)

Comment
Add comment · Show 2
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 Broheim · Oct 03, 2012 at 02:01 PM 2
Share

in a 3d animation no object ever "truly" moves. they always teleport. You just teleport your objects by small amounts and in short iterations. $$anonymous$$AGIC!

Check out Time.deltaTime :)

avatar image hoffmanuel · Oct 03, 2012 at 02:05 PM 0
Share

don't modify single position attributes directly, wouldn't even be valid if you used C#

it would be better to use a vector direction, a speed and Time.deltatime

Or, the better and ment-for-this way, add a CharacterControllerComponent and use it as discribed at http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.$$anonymous$$ove.html

3 Replies

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

Answer by Dragonlance · Oct 03, 2012 at 02:42 PM

You will have to check for collisions and as the objects collide, move your character back or do not move it this frame. If you want it to push the game objects, program it.

Alternatively use the integrated physics system and mark the collider on your character as kinematic. Then you will have control, but it pushes other colliders out of the way.

You will have to tell the objects how they behave, if you do not make sure something happens as you want it, it will not happen.

(Actually there is a lot of stuff unity makes easy, but you have to give life and behaviour to your game objects yourself)

And one little tip:

Frame times can vary so this will give you a constant speed:

 if (Input.GetKey(KeyCode.W))      
 {
     transform.position.z += 0.3 * Time.deltaTime;
 }
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 TerraQuartZ · Oct 03, 2012 at 04:54 PM 0
Share

ah thanks a lot, i used a rigidbody with mesh colliders. i also kinda solved it by reducing speed to 0.1 i shall upload a screenshot of what i have

avatar image
0

Answer by AyJayKaySoft · Oct 03, 2012 at 02:05 PM

If you want your objects to collide, you have to give them colliders and rigidbodys. And yes in an digital world every move is an kind of teleporting. Even rigidbodys will check where they intersecting for the simulation. You may use CharacterController if you want to stop at colliders. http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.html

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 AyJayKaySoft · Oct 03, 2012 at 02:06 PM 1
Share

sorry 13 sec to late XD

avatar image TerraQuartZ · Oct 03, 2012 at 05:08 PM 0
Share

i already gave them rigid body's and colliders sorry for not telling

avatar image
0

Answer by BBG · Oct 03, 2012 at 05:03 PM

I think you are looking for transform.Translate() to use for smooth movement instead of jumping by a set amount as you are doing now by changing position directly.

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

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

15 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 avatar image avatar image

Related Questions

Car made of boxes teleports on hard collision 0 Answers

Problem with objects colliding and IsSleeping (C#) 1 Answer

CC Collisions, Locking Y Axis 1 Answer

A* pathfinding project - How to avoid other moving objects? 1 Answer

How come the Trigger teleports when its not supposed to! 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