Tag Info

New answers tagged

0

Remove the else { alerted = false; } And move the alerted = false; to BEFORE the for-loop: public void enemyTransform_TL_TR() { alerted = false; for (int i = 0; i < 4; i++) { ... You're clearing the boolean value on the last iteration, making the previous 3 checks useless.


0

The block of code you posted is working fine. First of all, be sure your player has a 3D collider ( box, capsule, etc ) in it. Second, be sure to change the material color in one spot only. If the color is blinking, maybe you're changing it in two different updates. Third, I don't think it is the source of the problem, but Unity documentation encourage ...


0

You might check to see if the triangles in each index variant are still listed in the same order (for instance, sometimes it's A0 B1 C2 D3, sometimes it's B0 C1 D2 A3, but always the same triangles come before and after each other in the index). If that's the case, you might be able to calibrate when you instantiate your gameobject by shooting a raycast at ...


1

http://docs.unity3d.com/ScriptReference/Ray.html This shows us that ray takes 2 parameters; an origin( the place the ray is being cast from ), and a direction. This is where your code is wrong, you pass in the enemy position for an origin, and pass in the player's position for the direction. A direction should be a normalised vector. To get the direction ...


1

This is a problem that has several solutions and optimizations to it, especially in 3d. 2d, there are fewer but still more than one "right answers". If you understand the first answer, but not this one, it has a good chance of being "Fast enough" on modern hardware there won't be a problem. Another solution is Quadtrees: ...


0

I suggest for a quick fix just implement your weapon using collision boxes with trigger assignments then go from there void OnCollisionEnter(Collision col){ if(col.collider.gameObject.name == "Enemy" /*or tag*/){ //apply damage! } } P.S Thanks for helping me fix send message haha I hope this helps you!


0

You are performing two raycasts, but only storing the result of the first one in hit. So the renderer you access to change material color to red is the renderer of the player, not the renderer of the tile. Add 'out hit' as a parameter to your second Physics.Raycast call: Physics.Raycast(user.transform.position,Vector3.down, out hit, 10);


1

As per @Krom Stern's suggestion, this is my solution to this problem. An incomplete, but working box cast algorithm for uniform grid: http://jsfiddle.net/d5ab67fj/1/. It currently is missing the end point cases and it only increment in X direction, but the algorithm itself is working. It will not miss any cells that the box would hit and it will not ...


1

First thing you should do to save some time is eliminate the ones that can not match. To do this, calculate the smallest rect that contains the circle. Intersect that with whatever rect you think might intersect with it (loop over all of them, most likely). Two rectangles intersect if they overlap both horizontally or vertically. There are three ways an ...


0

Given that you cast just one ray and that objects can take no more than closest neighbor tiles in any of 8 directions, you just need to expand your resulting list of tiles 1 tile in every direction. Either while you detect the tiles rays goes through, or after you have the whole list - depends on your needs/constraints.


3

Your problem is not the ray cast, but that your grid cell doesn't reflect its actual state or in other words it might contain objects that it doesn't know about. When a certain object intersects a grid cell, the grid cell should know about it, this way when an object intersect multiple grid cells each grid cell should have a reference to that object, this ...



Top 50 recent answers are included