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 DrunkGamer · Aug 16, 2013 at 12:55 AM · playerrotate objectmovingmove an objectteleporting

Object goes trough everything (Teleporting?)

I have a little big problem. I'm making a game and i need an object to follow the player when not seen, everything is working fine except for 1 thing... The object moves trough the floor, walls and everything on it's way without giving a single fuck about it (like a baws). Idk if it's because of the LookAt or the Translate variables, but i think the second one causes it. It's like it teleports instead of moving behind the player.

Here is the script:

 #pragma strict
  var player : Transform;
 
  var statue : Transform;
 
  var speed : float = 0.5;
  
  var RockDragging: AudioClip;
     
 function Update(){
 
  if(renderer.isVisible == false){
 
      statue.LookAt(player);

      statue.Rotate(player);
      
      statue.Translate(speed*Vector3.forward);
      
      audio.clip = RockDragging;
      
      audio.Play();
      
     }
 
 }
 
 function OnBecameVisible() {
 
      audio.clip = RockDragging;
 
      audio.Pause();
      
 }
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 RomanorumLegio · Aug 16, 2013 at 04:09 AM

The first thing I notice is that you are using transform.Translate which ignores physics. If you want it to collide with other objects, both involved objects should have colliders, and you should use ridgedbody.AddForce to move said objects.

More than likely you will have to set up a form of path-finding too, and I have no experience with that.


Edit

I know that I can blabber at times, so let me make a checklist to clear things up:

  1. Check that the moving object is a rigidbody. (tutorial)

  2. Check that both the moving object and the player have colliders. (tutorial)

  3. Set the statue variable to a RigidBody instead of a Transform

  4. Set the object to move with AddForce instead of translate (tutorial)

Final script should look something like this:

 #pragma strict
 var player : Transform;
 var statue : Rigidbody; //redefined Transform to Rigidbody
 var speed : float = 0.5;
 var RockDragging: AudioClip;
 function Update(){
     if(renderer.isVisible == false){
         statue.LookAt(player);         
         statue.Rotate(player);         
         statue.rigidbody.AddForce(speed*Vector3.forward); //changed movement by translate to addforce    
         audio.clip = RockDragging;         
         audio.Play();         
     }     
 }     
 function OnBecameVisible() {
     audio.clip = RockDragging;
     audio.Pause();  
 }
 //I reformated to what I'm used to. There is no need to change your formating.
 //If there is a syntax error, I appologize. I almost exclusively use C#.

Comment
Add comment · Show 5 · 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 RomanorumLegio · Aug 16, 2013 at 04:10 AM 0
Share

By the way, are you making something similar to SCP : Containment Breach?

avatar image DrunkGamer · Aug 16, 2013 at 09:11 PM 0
Share

Sorry for the late answer. I'm planning on making something similar to SCP-173, if you want to compare it with something related with the SCP Foundation universe

avatar image DrunkGamer · Aug 16, 2013 at 09:47 PM 0
Share

Also, i didn't really understood what to do. Can i haz example script?

avatar image RomanorumLegio · Aug 17, 2013 at 03:08 AM 0
Share

No worries about the speed; we all have obligations in real life to fulfill.

avatar image RomanorumLegio · Aug 17, 2013 at 03:31 AM 0
Share

I updated my answer to something that should help you more.

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

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

Related Questions

Object rotating around object at two levels 1 Answer

Attach a Player to a moving GameObject 0 Answers

Teleporting Script Doesn't Work With Anything But The Player 1 Answer

Mouse as a throttle 1 Answer

Helicoper Movement Help 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