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 /
  • Help Room /
avatar image
0
Question by Rembo4Fight · Feb 07, 2018 at 03:23 PM · scripting problemtimemathfpingpong

Separate Numbers ?

Hello :) I have the code where is i have two variables : thresX and thresY.

They are going back and forth and have the same number. So what I want to do is that to make them not having the exact number like -1 and -1.

**But I want to make them have like -1 and another 1.

Here is the code, maybe i need to change time or something like that?**

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class ScoreTextOffset : MonoBehaviour {
 
     public Material mainMat;
 
     public float thresX;
     public float thresY;
 
     static float t;
 
     public float max;
     public float min;
 
     void Start () {
         thresX = mainMat.GetFloat ("_UnderlayOffsetX");
         thresY = mainMat.GetFloat ("_UnderlayOffsetY");
     }
 
     void Update () {
         t = Time.time;
         thresX = min + Mathf.PingPong(t,max);
         thresY = min + Mathf.PingPong(t,max);
 
         mainMat.SetFloat ("_UnderlayOffsetX", thresX);
         mainMat.SetFloat ("_UnderlayOffsetY", thresY);
     }
 }

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 Harinezumi · Feb 07, 2018 at 03:38 PM 0
Share

Could you please clarify your question? It is not clear what "make them not having the exact number like -1 and -1" "But I want to make them have like -1 and another 1" means.

avatar image Rembo4Fight Harinezumi · Feb 07, 2018 at 03:46 PM 1
Share

Okay I have 2 variables: thresX; thresY They are having the same amount from PingPong function. I want them to have separate result, like moving each of them to different directions(When first have "-1" and the second "1". I needs just one of them, to move to another direction like not from -1 to 1, but from 1 to -1.

avatar image Harinezumi Rembo4Fight · Feb 07, 2018 at 03:59 PM 1
Share

Do you mean like this?

      t = Time.time;
      thresX = $$anonymous$$ + $$anonymous$$athf.PingPong(t,max);
      thresY = max + $$anonymous$$athf.PingPong(t,$$anonymous$$); // switched $$anonymous$$ and max, so now it goes in the other direction
avatar image Rembo4Fight Harinezumi · Feb 07, 2018 at 03:47 PM 0
Share

I hope i'm not convince you more)

1 Reply

· Add your reply
  • Sort: 
avatar image
-1
Best Answer

Answer by yummy81 · Feb 07, 2018 at 03:57 PM

Replace these lines of code:

          thresX = min + Mathf.PingPong(t,max);
          thresY = min + Mathf.PingPong(t,max);
 
 

with these:

 thresX = min + Mathf.PingPong(t, max);
 thresY = min + Mathf.PingPong(t, max);
 thresY *= -1;
 
 
 
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

182 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 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 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 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 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 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 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

what exactly does Time.time do in Mathf.PingPong? 3 Answers

Mathf.SmoothStep sequence Time problem 1 Answer

Pausing a Mathf.PingPong at the ends 0 Answers

How is it possible to verify values and is they are correct activate objects ? 0 Answers

Why is Vector2.SignedAngle not working as expected? 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