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 Pemu · Jul 26, 2013 at 04:43 PM · animationandroidmovementmovement scriptlearning

Unity Android movement

Hi. I learn Android scripts. I have to create this movement:

When I hold finger on screen, my hero goes his way.

I don't have any idea, so maybe you help me? I begin in Android.

Thanks;)

Comment
Add comment · Show 4
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 perchik · Jul 26, 2013 at 09:02 PM 0
Share

Your question is very very very broad. What have you tried? What are you stuck on? What is your background? Right now it sounds like you want someone to just write a bunch of code for you, and unfortunately, that's not how Unity Answers works.

avatar image Pemu · Jul 26, 2013 at 09:04 PM 0
Share

I'am from $$anonymous$$nd, so I don't understand English well. I question who help me, maybe who have this script and share on this question.

avatar image perchik · Jul 26, 2013 at 09:05 PM 0
Share

Have you written any code to solve this problem?

avatar image Pemu · Jul 27, 2013 at 06:56 AM 0
Share

Yes, of course, I have a simple move at the moment but this more suits me;)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by RyanZimmerman87 · Jul 27, 2013 at 10:15 AM

I currently have an Android project where you tap the screen to control where the player goes. You could easily change it to be holding down your finger by changing:

if (Input.GetButtonDown ("Fire1"))

to:

if (Input.GetButton ("Fire1"))

So without the details of what kind of camera view you have it's a bit hard to answer properly. But essentially you can shoot a ray from the camera's point of view. Where this ray hits the ground or any objects you interact with is where the player will move.

I can't offer much beyond that simple advice despite being quite far in my games development. I wasn't able to find any tutorials for setting up a game with these kind of controls so everything I did was just trial and error and freestyle programming.

But essentially you cast rays to determine where to go, then you must do ridiculous things to get it to work correctly and look good for your specific project, so I can't go into those details haha.

I can give you the starting point though:

 if (Input.GetButton ("Fire1"))
 {
 
 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 RaycastHit rayHit;
 
 if (Physics.Raycast(ray, out rayHit, 150)
 {
 
 rayVector = rayHit.point;
                 
 playerDestinationVector = new Vector3 (rayVector.x, this.playerTransform.position.y, rayVector.z);
 
 rayHitObject = rayHit.collider.gameObject;
 
 stringRayName = rayHitObject.name;
 }


That gives you the basic things you need to work with.

And after that let the madness begin...

Comment
Add comment · Show 2 · 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 Pemu · Jul 27, 2013 at 10:21 AM 0
Share

Ok, thx for answer, so I hope it will work ;)

avatar image RyanZimmerman87 · Jul 27, 2013 at 10:28 AM 0
Share

It works but if you aren't at least twice as smart as me it won't be easy haha. This kind of system requires excessive amount of control structure compared to a PC game using (WASD) controls.

Here's a screenshot of the current project I'm using this kind of system with so you can have a better idea if it might work for what you are trying to do:

http://tinypic.com/view.php?pic=2ut6qgo&s=5

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

Everything is choppy... How can I make object movement more fluid? 3 Answers

Animation in android game not working 2 Answers

How can I drag a GameObject along a fixed line? 2 Answers

Interrupt a MoveTowards when triggering 2 Answers

Joystick animation on android 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