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 siddharth3322 · Nov 25, 2014 at 11:32 AM · player movementflying

Copter movement

At present I am trying to behavior some thing like following 2d game : Retry

Basically above game contains following type of movement. I have taken snapshot for that

alt text alt text

I can't able to figure out starting point for this. Right now I am considering, I have to choose some point far from copter and based on that point rotate copter around that point.

I don't know whether I am right in this. So that I need some suggestion from your side because this type of movement I have seen first time in copter game.

Please give some suggestions and tips in this.

flight3.png (11.4 kB)
flight1.png (13.7 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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by koray1396 · Nov 25, 2014 at 11:46 AM

not tested, but the following should work for the movement and rotation of the copter.

 rotation = rotationSpeed * rotationSide //rotationSide > 0 for no rotation, 1 for counter-clockwise, -1 for clockwise.
 transform.Rotate(Vector3.forward * rotation * Time.deltaTime);
 transform.position += transform.right * Speed * Time.deltaTime;
Comment
Add comment · Show 7 · 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 siddharth3322 · Nov 25, 2014 at 11:49 AM 0
Share

How to decide rotationSide? Based on which parameter I have to decide this value?

avatar image koray1396 · Nov 25, 2014 at 11:53 AM 0
Share

you have to decide rotationSpeed and speed of the copter. you should assign rotationSide with your Input, like;

 if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftArrow)){
     rotationSide = 1;
 }
 //etc...



avatar image siddharth3322 · Nov 25, 2014 at 11:55 AM 0
Share

I am trying to develop game for android only. So I have only tap available for moving plane.

I think first you have to view copter's actual movement first. Then you give better answer.

avatar image koray1396 · Nov 25, 2014 at 12:03 PM 0
Share

ok... you really should figure out these yourself man. I don't know how Retry works, a simple touch system would be like this. If you touch right side of the screen, copter rotates clockwise, else, left side would rotate counterclokwise.

 void DetectTouch(){
     float rotationSide = 0f;
     if(Input.touches.Length > 0){
         for(int i = 0; i < Input.touches.Length; i++){
             Vector2 tp = Camera.main.ScreenToViewportPoint(Input.GetTouch (i).position);
             if(tp.x >= 0.5f){
                 rotationSide -= 1f;
             } else {
                 rotationSide += 1f;
             }
         }
     }
     rotationSide = $$anonymous$$athf.Clamp (rotationSide, -1f, 1f);
     rotation = rotationSpeed * rotationSide //rotationSide > 0 for no rotation, 1 for counter-clockwise, -1 for clockwise.
     transform.Rotate(Vector3.forward * rotation * Time.deltaTime);
     transform.position += transform.right * Speed * Time.deltaTime;
 }
avatar image siddharth3322 · Nov 25, 2014 at 12:30 PM 0
Share

Thanks @koray1396, I have up vote your answer because I am getting something from it. There is no need to calculate rotationSide because I have to move only right side only. Value 1 to rotationSide works perfectly here.

Using your answer, I am near to correct behavior of copter. Just one thing remains, On touch first copter has to travel some what horizontal distance then start movement as per above coding but horizontal movement is some what slant in direction.

Please give final suggestion for this.

Show more comments

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

27 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

Related Questions

Player Momentarily Stuck at Edges of Screen! 1 Answer

how do I make a obeject (player) move the way it's pointing ? (like a jetpack) (c#) 1 Answer

left and right player movements restricted to a circle 1 Answer

How to cut the leg / arm of a character 1 Answer

How to handle stairs by hand 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