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 blackshtormx · Jun 12, 2015 at 11:21 AM · collisionwallthrough

object goes through walls(no, dats nnot what r u thinkig about)

so, i have cylinder that moves up and down, it has rigidbody and capsule collider elements attached. so the problem is that if i'm touching green wall, ball goes through it. but i'm sure its not because of its speed, i took into account it, and made max speed(its 15). this cylinder sometimes is working fine, but sometimes not. here's whats happening: alt text

and here is how it has to be: alt text

my controller script:

 var speed = 0.0f;
 var speedUp = 0.2f;
 var MUS = 0.1f;
 var UpSpeed = 0.0f;
 var DownSpeed = 0.0f;
 var cameraLose : Camera;
 var mainCamera : Camera;
 var collide : boolean = false;
 var CollideUp : boolean = false;
 var CollideDown : boolean = false;
 var maxSpeed = 2;
 var me : GameObject;
 var score = 0;
 var scoreGui : TextMesh;
 function Start () {
 
 me.GetComponent.<Renderer>().enabled = true;
 
 cameraLose.enabled=false;
 mainCamera.enabled=true;
 
 }
 
 function Update () {
 //checking speed    
     if(UpSpeed==15){
     UpSpeed=15;
     }
 
     if(DownSpeed==15){
     DownSpeed=15;
     }
     
     if(speed<maxSpeed){
     speed+=speedUp;
     }
     else{
     speed=maxSpeed;
     }
     transform.position += Vector3.right * speed * Time.deltaTime;
 slow();
 
 }
     
 
 function FixedUpdate(){
 //controlling object
 if(Input.GetKey("w")){
     if(CollideUp==true){
     UpSpeed=0;
     }
 
 }
 if(Input.GetKey("w")){
     if(CollideUp==false){
     transform.position += Vector3.forward * UpSpeed * Time.deltaTime;
     UpSpeed+=MUS;
 }
 }
 
 if(Input.GetKey("s")){
     if(CollideDown==true){
     DownSpeed=0;
     }
 
 }
 if(Input.GetKey("s")){
     if(CollideDown==false){
     transform.position -= Vector3.forward * DownSpeed * Time.deltaTime;
     DownSpeed+=MUS;
     }
 
 }
 }
 
 //speedUp controlling
 
 function slow(){
 if(Input.GetKeyUp("s")){
 
 do{
     DownSpeed-=MUS;
     //transform.position -= Vector3.forward * DownSpeed * Time.deltaTime;
     yield WaitForSeconds(0.01f);
     slowDownS();
     }while(DownSpeed>0);
 }
 
 if(Input.GetKeyUp("w")){
 do{
     UpSpeed-=MUS;
     //transform.position += Vector3.forward * UpSpeed * Time.deltaTime;
     yield WaitForSeconds(0.01f);
     slowDownW();
     }while(UpSpeed>0);
 
 }
 }
 function slowDownS(){
 if(CollideDown==false){
 transform.position -= Vector3.forward * DownSpeed * Time.deltaTime;
 }
 }
 function slowDownW(){
 if(CollideUp==false){
 transform.position += Vector3.forward * UpSpeed * Time.deltaTime;
 }
 }
 //collisons checking
 
 
 function OnCollisionEnter(collision: Collision) {
 
 //taking up points
     if (collision.gameObject.tag == "points"){
          score+=10;    
         scoreGui.text=score.ToString();
     gameObject.Find("score int").SendMessage("addScore", score);
  }
  //if we collide with obstacle die
  if (collision.gameObject.tag == "Obstacle"){
  collide=true;
   mainCamera.enabled=false;
  cameraLose.enabled=true;
  //me.GetComponent.<AudioSource>().Play();
  me.GetComponent.<Renderer>().enabled = false;
  die();
  }
      //make character not to go through walls
      if(collision.gameObject.tag=="wallUp"){
     CollideUp=true;
     }
     if(collision.gameObject.tag!="wallUp"){
     CollideUp=false;
     }
     if(collision.gameObject.tag=="wallDown"){
     CollideDown=true;
     }
     if(collision.gameObject.tag!="wallDown"){
     CollideDown=false;
     }
 
 }
  
 
 
 //killing player
  function die(){
  yield WaitForSeconds(0.2f);
 gameObject.Find("score int").SendMessage("show");
   Destroy(gameObject);
  }
 

and, yup i also tried to change fixed timestep in time manager, and i changed it to 0.02, i leaved maximum allowed timestep and time scale not changed.

capture2.png (11.3 kB)
capture3.png (961 B)
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

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

2 People are following this question.

avatar image avatar image

Related Questions

Going through wall 2 Answers

Camera looking through objects when touching 1 Answer

Player rotating after wall collision 1 Answer

Make an instantiated cube destroy a wall on collision 1 Answer

Collision between Player and a Wall 2 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