- Home /

# position coins in parabolic path

Hi developers,

Please help this new bee.... I want to place the coins in parabolic path (using the parabolic equation) just like the coins placed in subway surfer. I am trying very hard but unable to click the solution.

I am working on game which is similar to Subway Surfer in which the character is running. What kind of explanation is required further?

Your help will be remembered ever. Thanks

What's your actual problem? Do you know how to compute a parabolic path? Are you having problems computing a location on a parabolic path? Do you know how to program? What have you tried already? What does your code look like? I am happy that you will remember my help. I'd be happier if your question was more detailed so I could spend the day with a smile on my facing knowing that my help allowed you to move forward with your project.

Graham your right, but could you be a little less rude
**Do you know how to program** Is very derogatory

You could instead politely tell him that answers does not give people codes and ask for more information

There was nothing wrong with what Graham said, I agree entirely. What he said wasn't rude, too many people come on here expecting "developers" to script their game from start to finish. Have a go at the script and then if you cannot figure it out, ask for help. That is all.

Graham I don't know how to compute parabolic path in 3D. I know the formula (y = a(x*x)+bx+c) but don't know how to find out the values of the constants, how to apply constant values in the formula.... that's why I was unable to form the parabola. I don't have knowledge of the 3D mathematics, which is the main thing. I want to learn maths but source is unavailable.

I know programming and is my passion.

The thing coming across here is that I would need to change the form of parabola depends on the speed of character.

The parabolic path of the coins will be long when it will run fast and small at slow speed.

I can't go with placing the coins by myself even though I can because I want to know the way to use parabolic equation in 3D games. Using formula allows me to make the placement of the coins dynamic and the coins will be ordered based on the speed of the character.

**Answer** by RyanZimmerman87
·
Apr 11, 2013 at 10:18 PM

Set the start point of a coin as a Vector 2 or Vector 3 position depending on your game type.

Example: Vector3 coinOneVectorPosition = new Vector3 (0,0,0);

```
Vector3 coinTwoVectorPosition = new Vector3 (0, 1, 1);
Vector3 coinThreeVectorPosition = new Vector3 (0, 3, 2);
Vector3 coinFourVectorPosition = new Vector3 (0, 6, 3);
//etc...
//you could make a function that uses these vector positional relationships.
//and then when you call the function give it the start vector position
Vector3 coinStartParabulaPosition;
//so for each parabula you would assign the coinStartParabulaPosition for where the first coin should be.
//you might want to use a prefab for your coins:
public GameObject coinPrefab;
//so in your function it might be something like this:
void coinParabulaFunction()
{
coinOneVectorPosition = coinOneVectorPosition + coinStartParabulaPosition;
//create coin automatically from prefab using Instantiate:
Instantiate(coin, coinOneVectorPosition, Quaternion.identity);
coinTwoVectorPosition = coinTwoVectorPosition + coinStartParabulaPosition;
Instantiate(coin, coinTwoVectorPosition, Quaternion.identity);
coinThreeVectorPosition = coinThreeVectorPosition + coinStartParabulaPosition;
Instantiate(coin, coinThreeVectorPosition, Quaternion.identity);
}
```

I did not double check the math and it's impossible to know if this will help you specifically because your question was so vague. I agree with others provide more information when asking questions :)

But this or something similar should allow you to just place an empty gameObject wherever you want the coin parabola to start.

if you do use a gameObject you would need to get it's transform.position for your coinStartParabulaPosition:

Start() {

coinStartParabulaPosition = transform.position

}

Or you could make the coinStartParabulaPosition be a public variable and assign it's location manually in the Inspector.

Thanks Ryan...

I got what I want.

Can you tell me how to do same thing i.e. place the coins in parabolic path *with the help of formula* ? because I want to use the formula as my character is changing its speed and so I need to change the parabola based on speed. If I will put the coins manually than it will be problematic to me as I need to do hardcoding my program.

I don't think anyone can write the function for you without knowing all the details of how fast your character will be moving, when they change speeds, how much their speed changes etc.

I'm not much of a math whiz in general so doing all the math for you would probably take me to long to be worth it considering the possibility I make any mistakes.

You could just use the speed to determine the distance between each coordinate?

Like if your base speed is 10 than each z position will be 1 meter apart for example.

If your speed changes to 20 it's 2 meters apart.

Speed 5 = .5 meters apart?

These changes should only be necessary for the distance between Z vectors positions I believe if your traveling forward that way? The distance moving left or right or up and down would be the same?

So instead of example:

coinThreeVectorPosition = coinThreeVectorPosition + coinStartParabulaPosition;

Instantiate(coin, coinThreeVectorPosition, Quaternion.identity);

You might do something like :

```
Vector3 coinTwoVectorPosition = new Vector3 (0, 1, 1);
Vector3 coinThreeVectorPosition = new Vector3 (0, 3, 2);
if (playerSpeed == 10)
{
vectorPositionZ= 1;
}
else if (playerSpeed ==20)
{
vectorPositionZ = 2;
}
//and then when you call the function to place the Vector you would go:
coinTwoVectorPosition = new Vector3 (0, 1, vectorPositionZ);
coinTwoVectorPosition = coinTwoVectorPosition + coinStartParabulaPosition;
```

It's hard to tell what kind of forumala you want, but maybe this example helps. If you have the kind of parabula you want already set up, I can't imagine it should be to hard to do this math if it's all just based on the playerSpeed? This should be able to be applied in a linear fashion to the distance between vector points as shown in this example above.

I could be missing something huge about what you are trying to do though like I said I'm not math whiz.

If you really want people to give you answers you should really provide the forumula you want to use and manipulate based on the players current speed. Right now I am just guessing at things that might help you...

Thanks to be of soft mind with the awesome details.

This is my code for character:

```
using UnityEngine;
using System.Collections;
public class CharacterMove : MonoBehaviour
{
public static int speed = 1;
void Update (){
transform.Translate(Vector3.forward * Time.deltaTime * speed);
}
}
```

### Your answer

### 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.