Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Oct 07, 2015 at 04:51 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by futureman12 · Oct 06, 2015 at 03:08 PM · collisioncollidercolliders

Transform movement going through Objects?(JS)

So I have a space themed seen set up and I have a big long script working really well, but im having troubles with it. Basically the ship just goes right through everything and ignores colliders of any type. Im using: transform.Translate (Vector3(0,0,1) * Time.deltaTime*speed); I was wondering if theres a alternative in JavaScript Any help would be greatly appreciated thanks!

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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by GlatiatorRX · Oct 06, 2015 at 03:47 PM

I have not used Javascript in a little bit. But the reason why your objects are most likely clipping is because using colliders do not mean there will actually be a reaction to the object. Simply translating an object will basically force it to a position, regardless if there is an object already there.

If you add a rigid-body and add a force, velocity, or impulse in a certain direction, instead of doing a translation, it should work better for you. I can't really say how to do that in javascript, but here is a reference. http://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html

Either do that, or you have to do your own computations to check if you are colliding and hence stop your ship from moving in said direction. Like do an on collision check and then restrict your movement along an axis, or some other direction.

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 GlatiatorRX · Oct 06, 2015 at 03:49 PM 0
Share

Basically what @taxvi commented above should work too.

avatar image futureman12 · Oct 07, 2015 at 04:05 PM 0
Share

This helped a lot, thanks!

avatar image
1

Answer by taxvi · Oct 06, 2015 at 03:27 PM

well, you can find it here, here, here, here and here unfortunately this means that this question is a spam :|

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 futureman12 · Oct 06, 2015 at 03:35 PM 0
Share

I looked through each of these and none helped. I have colliders on both objects and I don't have a way of referencing a character controller

avatar image taxvi futureman12 · Oct 06, 2015 at 03:44 PM 1
Share

well, ok, what transform.Translate() does is it teleports your game object each frame. it does not care about colliders or any forces. never move transform anywhere if you want to apply some physics. what you need to do is attach a rigidbody to the object that is going to move. then reference that rigidbody in your script. then use rigidbody.$$anonymous$$ovePosition() to move your object. rigidbody is able to consider all the colliders around it and collide with them ins$$anonymous$$d of going through them. and do this in FixedUpdate.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Tilemap Collider 2D preventing objects from moving 2 Answers

Does disabling colliders increase performance? 2 Answers

Why there is no Collider.IsTouching(...) ? 2 Answers

OnTriggerEnter does not work 1 Answer

Inconsistent Collision Detection 3 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