Tag Info

New answers tagged

3

There are a variety of ways to run code written in other languages in Unity. Most of these are platform specific. iOS: Since xCode will also compile C++ code, you could add the C++ code to the plugins directory and it will be built when you build the iOS app. You'd then define the function prototypes in C# so they are accessible from Unity. Documentation is ...


6

It might be silly, but you could make a small C++ program around the chess library, that takes a simple text board state or movelist as input and returns the AI's selected move. I don't know .net's system libraries off hand, but you can probably start it as a subprocess, send to its stdin and then poll its stdout for a reply. Local sockets are also a ...


1

The question you ask is ill posed: the problem is you are trying to map from a fundamentally 2 dimensional data set (positions on the screen) to a 1 dimensional data structure (your list). Binary search does not work in two dimensions, regardless of the mapping or hash. This is because for any potential hash, we can find points that are nearby in space but ...


0

This is easily accomplished by giving each object a Z value, a single value that determines how far away from the screen it is, if you want to look determine what object is in front of the other you just look at which one has the smaller z value.


1

The strategy we will follow is bounding the derivative, as the technique of splitting the query regions is very complex and probably very slow. Consider first a 1D function f, for which everywhere, |f'| < 0.3. We are given that f(3)=-2. What is a bound for f over the interval [1, 5]? Looking at the derivative bound, we have: | df | | -- | < 0.3 | dx | ...


1

Typically a physics engine will follow these steps: Broad-phase collision detection. Typically using bounding volumes, this reduces the set of all objects to a small subset of potentially colliding objects. Some data structures to handle broad-phase are AABB trees, KD-trees, Octrees, etc. Narrow-phase collision detection. From the subset of potential ...


3

You might be interested in a so called quad tree. A quad tree is basically a structure where you divide the area in boxes and put all objects in lists on these boxes. You can then check for collisions only in the boxes that are actually in range of the object. The advantage of quad trees over say 2d arrays is that you they scale very well, if you have a ...


2

First, do a preselection When a weapon has a low range, it usually doesn't make much sense to check it for collisions with objects at the other end of the world. You can drastically reduce the number of comparisons when you can narrow it down to objects in local vicinity. One option is to use a two-dimensional tree structure. These usually allow you to ...


0

I'm currently experimenting with a similar game-concept and what I do is the following: Iterate through columns (vertical) and check for 3 consecutive items of the same type. If that occurs, replace the last item of the match with a random, but different item. If one item has been changed, set a changed flag. Do the same for rows (horizontal). Also set the ...


1

Check: Loop over all tiles and check for matches (first loop over all rows horizontally and check for 3 in a row then check vertically same way). If no matches found - shuffle, else - exit. Shuffle: Make a list of all available items. Loop over all positions, for each position assign a random item from the list ensuring that no condition is violated ...


1

Diverse terrain can be created using various arithmetic adjustments of randomly generated numbers. As I'm sure you realize, adjusting your generated values (for example, multiplying by two) would change the result you have. If you are familiar with programs such as Photoshop or Paint.net you've probably heard of the concept behind multiplying colors, or ...


5

The task is actually highly parallelisable on the GPU. Here is an algorithm that should work, assuming e.g. a 1024×1024 source texture ST. create a 256×256 render target, RT1 run a fragment shader that reads from ST and writes to RT1 and does the following: for each fragment in the render target get the (x,y) fragment coordinates sample 16 pixels from ...



Top 50 recent answers are included