Tag Info

Hot answers tagged

6

An AABB is an axis-aligned bounding box. It is a box whose sides are aligned with the axes of the world, and which has extents along each axis. By "AABBvsAABB" your instructor is trying to tell you to make an intersection test between (versus) two AABBs, finding whether they intersect, how they intersect, etc. There are algorithms to find intersections for ...


5

While D3D doesn't support quad primitives, there's nothing in principle wrong with continuing to draw them as a triangle list. First thing to realise is that the index buffer used to simulate quads with a triangle list can always remain static, so you can create it once only (during startup), then just reuse it every time you wish to draw. The code to ...


5

There's no documented way to do this in Direct3D; it simply does not have support at the API level for quads as a primitive type. D3D doesn't have an extension mechanism like OpenGL does, but in some cases driver vendors support enabling certain kinds of "extended" features by passing certain combinations of invalid or otherwise-nonsense parameters to ...


2

I was able to solve this using trig instead of vector math. Here's how it looks as a triangle. Notice that since this is meant for a computer coordinate system, the y+ axis is down. Also the angles are as such: x+ = 0°, y+ = 90°, y- = -90°, and x- = ±180° Additionally, we know that line B's angle is ∠B = -10°. The speeds don't matter since they can be ...


2

Unity 5 just came out, and they changed the API for a call like object.rigidbody Specifically, every component shortcut other than object.transform has been removed, since the Transform component is the only one that all objects have. All the other shortcuts only applied a fraction of the time. Now you need to access the Rigidbody component using ...


2

One simple way of doing it could be to make a few alternate versions of the script and have different AI profiles for the enemies (just give them a random one when created). This way you could have one type that goes straight ahead like you have now, but also others that try to get the player by curving right or left. Maybe even one that makes some random ...


2

The main importance in a case like this is to be able to use hardware acceleration and being able to upload your map to the GPU for smooth zooming. Usually using a game engine tends to restrict how you access the hardware, whereas using OpenGL/WebGL directly will not get in your way (but also won't assist you with common tasks either). In this case it ...


2

You can load the "next" level with: Application.LoadLevel(Application.loadedLevel + 1); You will need to either: Setup the last level as a non-gameplay "You Win!" scene with a different exit condition or; Manually check you don't exceed Application.levelCount. And you can count the number of objects with a given tag with: int campFireCount = ...


2

Collision detection like this can be tricky. However - I do see a way around your problems. First, you definitely want to round off your "collision" position. In most cases, decimal numbers will cause collision problems when you're working with pixels (which are measured in whole numbers, usually). Here are two methods I thought up, in image form: (sorry ...


2

The equations of motion for a differential drive machine are as follows, where x, y, θ, and l are the 2D position, orientation, and drive shaft length (distance between wheels) respectively: While a tank is not quite an ideal differential drive machine, this should be a sufficient approximation. Translating this into code using a simple Euler ...


1

You don't want to actually resize the sprite. What you want to do is resize the texture this sprite is being rendered on. Once you get the texture you can call Texture2D.Resize(Screen.width * 0.2f, Screen.width * 0.2f) If you're not sure which texture you are using, you can call Sprite.texture to get the texture used. If you wanted to, you could even do ...


1

Please consider this first-party library; it is from MS, so if it is not-third-party enough for you, it will make your life considerably easier. It provides an interface to DX11 that is very similar to XNA. Specifically, SpriteBatch, SpriteFont, etc.. Rastertek and Reimer's are generally helpful. For Rastertek, I linked directly to their DX11 2D tutorial, ...


1

You can create a Cell and fill that with a tile from the TileMapTileSet, then set that cell at (x, y) coordinates in a particular Layer. For example, the following code sets the tile at (32, 64) in a layer to tile 42 from tile set tileset_name; TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("some_layer_name"); Cell cell = new Cell(); ...


1

You can manually scale it by setting the size to be a percentage of the screen width/height. Make a variable(if you want) that is a value from 0.0 to 1.0 and multiply it by Screen.height(or .width). That is your new width/height. You should make the position relative also. Nevermind that part, you said the anchor works.


1

Yep, a flag works just fine, when used correctly: void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag=="Player"){ inTrigger = true; } } void OnTriggerExit2D(Collider2D other) { if (other.gameObject.tag=="Player"){ inTrigger = false; } } void Update () { if(inTrigger && Input.GetKeyDown(KeyCode.E)) ...


1

I would've added collider around the edges that will collide only with these characters' bodies. Then use OnCollisionEnter event (and maybe also check the tag of the colliding object) to turn around. Could also use ray-casting... but I like the collider solution better. It's much more reliable.


1

The easiest way to side-step this is: x = (int)x; y = (int)y; or x = round(x); y = round(y); Are either of these acceptable, visually? Edit: Diagram of modified SuperDoggy "Method 1" using floats: Precise overlap amount given by colliders Since you have so many cases, it may be helpful to make a helper for jiggling the rect: class CollisionHelper ...


1

Everything is green, so I can't tell what is is a player, what is a block, and what "2" means or is supposed to mean. I did make you this, however: The diagram can be mirrored and/or rotated and, with a tweak to the math, match any orientation of collider and collidee. Let me know if this isn't what you need and I'll try again. These triangles are all ...


1

In your Update Function, You need limit transform.position.x range, like this: void Update() { float targetX = Mathf.Max(levelMinX, Mathf.Min(levelMaxX, cameraTarget.transform.position.x)); float x = Mathf.SmoothDamp(thisTransform.position.x, targetX, ref velocity.x, smoothTime); }


1

Just make the main camera a child of the player object in the hierarchy, then move it to where you want it in the scene view with the translate/rotate tools. Don't make it overly complicated with code. Or apply the same control scripts and colliders to the camera as to the player object.


1

According to what evaluated in the comment section, your problem was that you had to set transition conditions to be greater then some_value instead of equal.


1

Are all coins doing the same animation? You could make a method in the Animation class that takes a coin as an argument, then performs the animation on that coin. Then, on another class, you make a loop that traverses the coin list and calls the method in your Animation class, therefore animating each coin as you go through the list. You can also add delay ...


1

First big thing to remember is that collider and trigger events should be called with the "collider other" in the brackets if we want to work with whatever caused the collision or trigger. // trigger event within rope OnTriggerEnter2D(Collider2D other) // send in the other collider (should always work) { if(other.tag = "tagUsedToIdentifyRope") // used a ...


1

I tried to solve it following @david van brink comment. P: intersection point (unknown) S1: car's starting point(2,2 here) S2: canon's starting point(3,12 here) |v1|: car's velocity length (25 here) |v2|: canon ball's velocity length (120 here) a: angle between the car's velocity and the X-axis (10 degrees here... or Pi/18) b: angle between the canon ball's ...



Only top voted, non community-wiki answers of a minimum length are eligible