Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 SleightOfCode · Aug 22, 2016 at 05:08 AM · iosplayer movementtaptomove

Tap n move style script not keeping player grounded

Hey everybody,

This might be something super obvious, but I think I just need another set of eyes on it. I'm making a game that's kind of loosely like slither.io (control wise), but with spheres rather than snakes that bump in to one another trying to force enemies off of a platform. It's being built for iOS, and my player is supposed to be in a constant state of motion and changing direction based on where the user taps the screen. That much is working but my player is also sort of bouncing and floating up towards the screen. I'd lock the Y position, but we need to be able to fall off the platform.

Admittedly this project fell into my lap a bit when I offered to do design work, and now I'm the sole developer - and not fantastic on the development side.

Huge thanks in advance.

Here's my working script.

 using UnityEngine;
 using System.Collections;
 
 public class TapNMove : MonoBehaviour {
 
     public float speed = 12;
 
     public float maxHeight = 1;
     public Vector3 pointInWorld;
 
     // Use this for initialization
     void Start () {
 
     }
 
     // Update is called once per frame
     void Update () {
 
         transform.position += transform.forward * Time.deltaTime * speed;
 
         if (Input.touchCount > 0) {
             // The screen has been touched so store the touch
             Touch touch = Input.GetTouch (0);
 
             if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved) {
                 // If the finger is on the screen, move the object smoothly to the touch position
                 Vector3 touchPosition = Camera.main.ScreenToWorldPoint (new Vector3 (touch.position.x, touch.position.y, 10));
                 transform.LookAt (touchPosition);
             }
 
             //if (transform.position.y > maxHeight) {
             //    transform.position.y = maxHeight;
             //}
 
         }
 
     }
 }
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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

iPhone profiler evaluation 1 Answer

Player2d Movement (rigidbody2d.velocity) with small vibrations, very similar to small collisions 1 Answer

Serialization of Dictionary> in Unity 4,6 0 Answers

Using AssetBundles as IAP Crashing 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