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 VIPINSIRWANI · Jul 10, 2013 at 01:20 PM · colliderraycastingcollision.contacts

Paddle which control by Cpu for Air hockey game Raycasting issue

Hello, I am making a Air Hockey game but another paddle which will be control by a CPU i am facing problem. Actually i am applying Ray-casting, Ray, Trigger Enter or Collision but it is not working smoothely ...What should i apply on paddle then it works fine.... I want to make this game Smooth...Anyone please suggest me what should i do for smoothness??

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 Spherical Cow · Jul 10, 2013 at 03:06 PM 1
Share

If you could post the code you are currently using, I would be happy to help out - but I will need a little more information first.

Exactly what kind of behavior are you trying to achieve with the paddle? Do you want it to follow the air hockey puck? Hit the puck back to the player? What do you mean by "smooth"?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by VIPINSIRWANI · Jul 11, 2013 at 10:30 AM

void Update () { pos2 = new Vector3(puck.transform.position.x,0.3359161f,puck.transform.position.z); newpos = new Vector3(0.2534024f,0.3359161f,puck.transform.position.z); transform.position = Vector3.Lerp(transform.position,newpos,(smooth*Time.deltaTime));

  if(puck.transform.position.x > -0.1068026)
     {
         transform.position = Vector3.Lerp(transform.position,pos2,(smooth * Time.deltaTime));
         
     }
     
          if(transform.position.x < -0.02968476)
          {
            transform.position = new Vector3(-0.02968476f,0.3359161f,transform.position.z);    
          }
     
     Vector3 fwd   = transform.TransformDirection(Vector3.right);


if(Physics.Raycast(transform.position,backR,out hit,0.5f)) { if(hit.transform.gameObject.tag == "Puck") { Debug.DrawRay(transform.position,backR,Color.black);
// Debug.Log("Back Left.."); /FRONT = false; BACK = false; LEFT = false; RIGHT = false; flag = false; FRONTL = false; FRONTR = false; BACKR = false; BACKL = true;/ flag = true; } else { flag = false;
} }

//Raycasting in all direction and void FixedUpdate() { if(flag) { //puck.rigidbody.AddForce(transform.position.x,transform.position.y,transform.position.z); //transform.Translate(newpos*Time.deltaTime); Debug.Log("Flag value is true..."); transform.position = Vector3.Lerp(transform.position,newpos, trans * Time.deltaTime); } Here the Smoothness means everything is happening very fast...

Comment
Add comment · Show 1 · 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 Spherical Cow · Jul 11, 2013 at 03:37 PM 0
Share

Please format properly using "code sample" button.

It will make the process a whole lot easier, as when I was reformatting your code it looked like there were a few things missing... just want to make sure it wasn't because of formatting. :-)

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

17 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

Related Questions

Paddle which control by Cpu for Air hockey game 0 Answers

raycast not colliding 1 Answer

Colliders on mecanim animal. 0 Answers

Multiple hit detection with Raycasting? 2 Answers

Raycast not hitting collider 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