`

Spawning randomly around edge of a circle and not in the center.

阅读更多

 

I am trying to randomly spawn around the edge of a circle and not in the center of the circle?
I am currently spawning with the following:
Random X spawn 100 to -100
Random Y spawn 100 to -100
How do I eliminate the center red area from the equation?

 

 

That sounds more like a square than a circle. You might want to just get two random numbers, one from 75 to 100, and another from 0-359. Then use those values to determine the right place relative to the spawner origin.

 

seriously, even if we don't have sin/cos. you can still do this to land points on a circle.

newP = oldP + normalize( vector2d( randomX, randomY)) * radius.

you just have to be sure x/y are not both zero.

with sin/cos you only need one random number and no worry about other situation.

newP = oldP + vector2d( cos(randomDegree), sin(randomDegree)) * radius.

 

Using some basic maths you could do this. Taking the equation for finding a point on the circumference of a circle you just sub the radius to be between your min and max area.

 

 

 

  • 大小: 32.2 KB
  • 大小: 132.2 KB
分享到:
评论

相关推荐

    a project model for the FreeBSD Project.7z

    This, combined with the vast amount of dependencies in the kernel and that it is not easy to see all the consequences of a kernel change, demands developers with a relative full understanding of the ...

    UE(官方下载)

    In this tutorial, we'll cover some of the basics of Unicode-encoded text and Unicode files, and how to view and manipulate it in UltraEdit. Search and delete lines found UEStudio and UltraEdit provide...

    C# Game Programming Cookbook for Unity 3D - 2014

    1.1.3 Using the Singleton Pattern in Unity...........................5 1.1.4 Inheritance.................................................6 1.1.5 Where to Now?.............................................

    Python Cookbook, 2nd Edition

    Building a Dict from a List of Alternating Keys and Values Recipe 4.13. Extracting a Subset of a Dictionary Recipe 4.14. Inverting a Dictionary Recipe 4.15. Associating Multiple Values with ...

    曲线拟合工具CurveExpert 1.0

    + if a data file was not read correctly, the filename in the status bar showed the unreadable file instead of the previous file. Fixed. + the common dialogs (file open/save, print) did not accept...

    Packt.Augmented.Reality.Game.Development.1787122883

    Innovate and explore the latest and most promising trend of AR gaming in the mobile gaming industry Book Description Have you been bitten by the Pokemon Go bug yet? If yes, then this is the right book...

    Unreal Engine 4.X By Example

    To create a basic actor, you can use the "Add New Actor" button in the toolbar or right-click in the viewport and select "Add Actor." Actors can be customized using the Details panel. ##### Objects,...

    关于c++中这个错误的解决方法Error spawning cl.exe

    ### 关于C++中“Error Spawning cl.exe”的解决方法 在C++开发过程中,遇到“Error Spawning cl.exe”这一问题时,不少开发者可能会感到困惑。本文将详细解析这一错误的原因以及提供有效的解决策略。 #### 错误...

    Sams.Teach.Yourself.Unreal.Engine.4.Game.Development.in.24.Hour

    In just 24 lessons of one hour or less, learn how to start using Unreal Engine 4 to build amazing games for Windows, Mac, PS4, Xbox One, iOS, Android, the web, Linux–or all of them! Sams Teach ...

    pyloris-3.2-win32

    Setting the --timebetweenthreads flag will adjust the amount of time between threads spawning. Adjusting this in conjunction with the --threadlimit will change the CPU load on your local machine. -W,...

    vxworks_kernel_programmers_guide_6.9

    1.4 VxWorks Configuration and Build .............................................................................. 5 2 VxWorks Configuration ..............................................................

    Compiling... ,Error spawning cl.exe错误

    ### "Compiling..., Error spawning cl.exe" 错误解析与解决方案 #### 一、问题概述 在使用Visual C++ 6.0进行编程时,不少用户可能会遇到一个常见的错误:“Compiling..., Error spawning cl.exe”。当尝试编译或...

    pexpect-2.3.tar.gz

    Pexpect is in the spirit of Don Libes' Expect, but Pexpect is pure Python. Unlike other Expect-like modules for Python, Pexpect does not require TCL or Expect nor does it require C extensions to be ...

    vs6.0安装及运行 和解决 Compiling... error spawning cl.exe 的问题

    路径是指文件在计算机中存放的位置,例如,文件 c.avi 在 D 盘的 a 文件夹中的 b 文件夹里存放,那么其路径就是 D:\a\b。在 Window 系统中,可以点击文件所在路径,显示当前文件的路径,然后可以复制粘贴路径。路径...

    Learning.Unreal.Engine.Android.Game.Development

    Each room will be more challenging than the previous, and as you develop, you will graduate from movement and character control to AI and spawning. Once you've created the game, you will learn how to...

    Hugh Howey - Machine Learning- New and Collected Stories (retail) (epub)

    Now comes Machine Learning, an impressive collection of Howey’s science fiction and fantasy short fiction, including three stories set in the world of Wool, two never-before-published tales written ...

Global site tag (gtag.js) - Google Analytics