• 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 MahMouD_FaRiD · Feb 25, 2015 at 08:58 PM · positionrandommathfpingpong

mathf.pingpong

hi, iam using mathf.pingpong, but it usually start position from (0,0,0), even if me change the position in the scene or from the script ! this code in Awake() to change the position randomly but didn't wok and also start from (0,0,0) randomRange = Random.Range (1, 10); transform.position = new Vector3 ((randomRange - 10f) + 10, transform.position.y, 0.0f); what can me do to solve this ? and if me want to move this object between negative and positive position, like from (-5, 5) in x ,, how to make this ? thank alot :)

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
0

Answer by meat5000 · Feb 25, 2015 at 08:08 PM

You probably need it in Update rather than Awake or Start

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 MahMouD_FaRiD · Feb 26, 2015 at 03:12 AM 0
Share

In Awake or Start.. Don't work

avatar image meat5000 ♦ · Feb 26, 2015 at 03:17 AM 0
Share

It did work. It just gave you 1 instantaneous return value instead of what you thought it was going to do.

For it to do what you want youve got to keep calling it.

Look at the docs. Its in Update and using time to vary the value.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Mathf.PingPong from a random position problems 0 Answers

Ping pong position using lerp 3 Answers

Spawn a gameobject in random position within an area? 2 Answers

Vector3.lerp and Mathf.pingpong not moving smoothly 3 Answers

Camera rotation around player while following. 6 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges