Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:28:23+00:00 2026-05-28T21:28:23+00:00

I am trying to develop a game in Unity where you jump from 2D

  • 0

I am trying to develop a game in Unity where you jump from 2D planet to 2D planet, each with its own gravitational pull (The game is 2.5D, technically, but all movement is along the X and Y axes). I would like to place landmines at random points along these planets using the parametric formula; this is the script that I’ve developed to attach them to the parent Planet object. However, mines are not appearing at the surface of the circles as expected, and are instead appearing very distorted in shape. What might I be doing wrong?

public class LandMine : MonoBehaviour 
{
    public GameObject mine;
    private GameObject landmine;
    private System.Random rand;
    private Vector3 pos;

    List<GameObject> mines;

    public void Start()
    {
        mines = new List<GameObject>();
        LevelStart();
    }

    public Vector3 ran()
    {
        rand = new System.Random(359);
        float angle = rand.Next();
        float value = angle * (Mathf.PI/180f);
            float x = (float) (0.5000001 * Mathf.Cos(value)) + 6;
            float y = (float) (0.5000001 * Mathf.Sin(value)) - 9;
            return new Vector3(x,y,0);
    }

    void LevelStart()
    {
        for (int i = 0; i < 5; i++)
        {
            pos = ran;
            mine = Instantiate(mine, pos,Quaternion.identity) as GameObject;
            mines.Add(mines);
        }
        foreach (GameObject m in mines)
        {
            m.transform.parent = this.transform;    
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:28:24+00:00Added an answer on May 28, 2026 at 9:28 pm

    The parameter you pass to the Random constructor is the random seed, not the range of numbers. If you want to generate new random numbers each time you start the game, use the parameter-less constructor. Also, declare the random number generator only once. It uses the time clock in order to initialize itself, but since the clock ticks very slowly (compared to the CPU clock frequency) it could generate the same random number several times if you create a new instance each time.

    static readonly Random random = new Random();
    

    Then generate a new angle with

    int angle = random.Next(360); // generates numbers in the range 0 ... 359
    

    or

    double angle = 2.0 * Math.PI * random.NextDouble();
    

    The formulas for the mine coordinates are

    mineX = centerX + radius * cos(angle)
    mineY = centerY + radius * sin(angle)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i usually develop for iPhone. But now trying to make a pong game in
I'm trying to develop/port a game to Android, but it's in C, and Android
I am trying to develop a car game in which opponents are coming from
I'm trying to develop a simple text-based hangman game, and the main game loop
I am trying to develop a .NET Web Project using NHibernate and Spring.NET, but
I'm trying to develop a card game with Flex, and I was wondering if
I'm trying to develop an oldschool NES-style video game, with sprite flickering and graphical
trying to develop web form using jquery. all i need is to have several
I'm newbie to Game programming. I'm trying to develop a simple shooting game. The
I trying to develop a game for iPhone by using Cocos2d. I need 'DRAG'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.