Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 DutchGuerrilla · May 29, 2015 at 12:50 PM · canvasspeedtowards

Vector2 MoveToward on HUD Canvas slow

The Vector2. MoveForward function seems to be what I want. I already used it for an enemy instance that walks arround with a speed of 3 time.Deltatime. But now I have an text object on my HUD canvas that starts at my players gameobject.position and I want to move it towards an text object in upper middle of the canvas. The first thing that difference from the enemy situation is the speed that I needed to configure higher to about 10 time.DeltaTime instead of 3 .. for the same speed? It seems even slower when I upload it to my android device?? Even with 100 time.DeltaTime??? But eventually it comes to it's target position :) Does this have something to do with the canvas that can change it's scale??

First I aline the source Hud canvas text object to the position of the player character:

streakPointText.transform.position = Camera.main.WorldToScreenPoint(new Vector3(characterTrans.position.x, characterTrans.position.y, characterTrans.position.z));

When the text object is in position, I move it towards the other main text object on the canvas with the following code in the update ():

float step = speedStreakText * Time.deltaTime; streakPointText.transform.position = Vector2.MoveTowards (streakPointText.transform.position, timeTextTrans.position, step);

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 taxvi · May 29, 2015 at 01:15 PM 0
Share

if you are not changing these variables from the outside everything should work. mm... why don't you feed characterTrans.position straight into that function ins$$anonymous$$d of the .x .y .z components? what is speedStreakText? where do you set it?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DutchGuerrilla · May 30, 2015 at 11:37 AM

The vector3 only accepts 3 arguments not just 1, so I have to feed it with these 3 seperate values. The speedStreakText gets it's value from another function in another script. The strange thing is that I use the same function moveTowards on my enemy and it's not on the canvas. By just filling in on the enemy a value of speed = 3 it moves acceptable. For the canvas I have to put a value of almost speed = 150 and it's still not on the same speed... I beginning to believe it has something to do with the canvas that scales to fit the screen and that has some influence on the speed which degrades it with some factor?

Comment
Add comment · 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
0

Answer by DutchGuerrilla · May 30, 2015 at 11:36 AM

To troubleshoot things I put a single object on my canvas and tried to move it to a other location on the canvas. But it's still slow moving. This is the code:

using UnityEngine; using System.Collections;

public class TestMoveTowards : MonoBehaviour {

 Vector2 targetPos;

 // Use this for initialization
 void Start () {
 
     targetPos = new Vector2 (0.0f, -25.0f);

 }
 
 // Update is called once per frame
 void Update () {
 
     float step = 3 * Time.deltaTime;
     transform.position = Vector2.MoveTowards (transform.position, targetPos, step);

 }

}

Comment
Add comment · 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

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

Canvas moves faster the second time it goes somewhere in the scene 2 Answers

Move Object A towards Object B at a definite speed 1 Answer

Jerky motion using moveTowards at high speed 0 Answers

Unity 2D Combat Text Issue With Multiple Enemies 2 Answers

How to get a Script to Use the Text its Assigned to 1 Answer


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