• 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 /
  • Help Room /
avatar image
0
Question by Lim_sihun · May 09, 2020 at 10:29 PM · physics

I'm making a Acceleration Tunnel in Unity, but the Result doesn't match with the Calculation.. WHY?!

Hi! I'm a high school student in (S) Korea!
I am making a Tunnel which Accelerate a Capsule when the Capsule goes through the Tunnel in Unity.
But the Result doesn't match with the Calculation.
Before explaining the code, this is my calculation

alt text



If I enter the values below, the result should be 22.36...m/s
tunnel length : 30m, capsule length: 10m, capsule mass : 1kg, Inital velocity of capsule : 10m/s, Force which the tunnel exert to the capsule : 5N.
but the simulator result in 30m/s
which is the value that I get when I apply the estimated velocity(22.36) in Initial velocity and redo the calculation...
how could this happen..?!

In the First code, I used the Rigidbody.Addforce to add force to the capsule.
This is the code.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerScript : MonoBehaviour
 {
     GCon Gmaster;
     int force;
     void Start()
     {
         Gmaster = GameObject.Find("GController").GetComponent<GCon>();
     }
 
     private void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.name == "Tun1")
         {
             print("tun1 Ent");
             force = Gmaster.T1F; //The force Tunnel1 exerts to the Capsule
 
         }
         if (other.gameObject.name == "Tun2")
         {
             print("tun2 Ent");
             force = Gmaster.T2F;  //The force Tunnel2 exerts to the Capsule
         }
         if (other.gameObject.name == "Tun3")
         {
             print("tun3 Ent");
             force = Gmaster.T3F;  //The force Tunnel3 exerts to the Capsule
         }
     }
 
     private void OnTriggerExit(Collider other)
     {
         print("Ext");
         force = 0;
     }
 
     private void FixedUpdate()
     {
         gameObject.GetComponent<Rigidbody>().AddForce(new Vector3(force, 0, 0), ForceMode.Force);
         // print(gameObject.GetComponent<Rigidbody>().velocity.x);
        
     }
     void Update()
     {
         
     }
 }


I Also used the ForceMode.Impluse but the same result...
And in the second attempt, I used the code I found in the forum.
This is the source.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerScript : MonoBehaviour
 {
     GCon Gmaster;
     int force;
     int mass;
     float Acc, Speed;
     Vector3 currFrameVelocity;
     Vector3 FrameVelocity, PrevPosition;
     void Start()
     {
         Gmaster = GameObject.Find("GController").GetComponent<GCon>();
         mass = (int)gameObject.GetComponent<Rigidbody>().mass;
     }
 
     private void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.name == "Tun1")
         {
             print("tun1 Ent");
             force = Gmaster.T1F;
             Acc = (float)Gmaster.T1F / mass;
 
         }
         if (other.gameObject.name == "Tun2")
         {
             print("tun2 Ent");
             force = Gmaster.T2F;
             Acc = (float)Gmaster.T2F / mass;
         }
         if (other.gameObject.name == "Tun3")
         {
             print("tun3 Ent");
             Acc = (float)Gmaster.T3F / mass;
         }
         print("Acc"+Acc);
     }
 
    
     private void OnTriggerExit(Collider other)
     {
         print("Ext");
         force = 0;
         Acc = 0.0f;
     }
 
     private void FixedUpdate()
     {
         Speed = Speed + Acc * Time.deltaTime;
 
        // print("Speed : " + Speed);
         gameObject.transform.position += new Vector3(Speed * Time.deltaTime, 0, 0);
 
         //the below code is for printing the velocity.
         currFrameVelocity = (gameObject.transform.position - PrevPosition) / Time.deltaTime;
         FrameVelocity = Vector3.Lerp(FrameVelocity, currFrameVelocity, 0.1f);
         PrevPosition = gameObject.transform.position;
         print(currFrameVelocity);
     }
     void Update()
     {
         
     }
 }


What could be the problem..? I was working on this for weeks.. but no result.... Could there be a problem in the 'time'..? Waiting for good advises! And apologizes for my short vocabulary and grammar...!

kakaotalk-20200509-234218593.jpg (54.9 kB)
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

Bounce, gravity and velocity 1 Answer

Car will only turn right (& ignored collders) 0 Answers

Why my gravity direction is rotating with transform.rotation? 1 Answer

Physics.Overlapsphere giving me a null reference exception 1 Answer

Gun RayCast Origin lags with fast moving object. Help? 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