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 Vetm · Jul 26, 2014 at 06:44 PM · collidertimecolliderstimescaletiming

Script is only working when slowing down timescale

I have a round based game with a player and an object called "check" that jumps to the position where the player is going (when an arrow key is pressed) and checks if it is going to collide with something. However it only works properly when I slow down the timescale to 0.01 or put in some waitForEndOfFrames.

This is my the code I use:

function Update(){ if (Input.GetKeyDown(KeyCode.LeftArrow) && spinning == false && left.active == true && scaling == false && !paused) { check.position.x = transform.position.x - transform.localScale.y-20; //moves Check to where the player will be standing after moving Move(Vector3.left); //moves the player } else if (Input.GetKeyDown(KeyCode.RightArrow) && spinning == false && right.active == true && scaling == false && !paused) { check.position.x = transform.position.x + transform.localScale.y+20; Move(Vector3.right); } else if (Input.GetKeyDown(KeyCode.UpArrow) && spinning == false && top.active == true && scaling == false && !paused) { check.position.z = transform.position.z + transform.localScale.y+20; Move(Vector3.forward); } else if (Input.GetKeyDown(KeyCode.DownArrow) && spinning == false && down.active == true && scaling == false && !paused) { check.position.z = transform.position.z - transform.localScale.y-20; Move(Vector3.back); } }

function Move(direction : Vector3) { deactivateColliders(); //disables all colliders of check children oldScale = transform.localScale.y; newScale = oldScale - 20; //player can go one field less after each turn //yield WaitForEndOfFrame(); //yield WaitForEndOfFrame(); activateCheck(); //enables all children of check activateColliders(); // enables their colliders again //code for moving the player... }

Check has four children. One for each direction (left, right, top, down). If one of the children hits a wall it disables itself.

"Check" checks where the player will be able to move in the next round.

The grey tiles are the children of check. As you can see the left one is disabled even if the player should be able to move there.

alt text

This problem does not occur when I uncomment the yields or slow down the timescale. I think there might be a problem with the timing. But pretty rarely it works fine. I hope that you understand my problem and have some ideas to solve it somehow. Thanks!

bug.png (18.5 kB)
Comment
Add comment · Show 1
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 CScherer549 · Jul 26, 2014 at 07:21 PM 0
Share

It sounds like a problem with how you're checking for walls/obstacles. Would you $$anonymous$$d posting that code?

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

I want to make the gameobject rigidbody.iskinematic=true for 3s and immune to damage when it triggers the collider and then false again 0 Answers

How do I make colliders collide when Tİme Scale is zero? 1 Answer

Accelerating Time Dramatically 1 Answer

Single Step (pause, resume), or externally clock game loop 0 Answers

Time.timeScale not working with Havok Physics 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