Hot answers tagged

4

The way fighting games work is with attack and collision boxes per frame. This way there is not a high/mid/low hit per se, a high-kick could for example hit a jumping character. In Street Fighter this looks like this: The hit is scored if a red box hits a opponents blue box. Red being the attack box and blue hit boxes In your example each frame of ...


4

Physics done on the GPU are usually cosmetic effects. Particles are a good example, but hair and tall grass are similar. The GPU is very good at doing a massive number of calculations and since it also handles the drawing if these things it is a good match. A GPU isn't very fast at communicating the results back to the CPU. This is why physics used in ...


2

I think you may be misunderstanding what the Equals() method does - it's checking whether the GameObject instance col.gameObject is equal to whatever you pass in as an argument. You're passing in a Boolean value, which is not a GameObject, so the result will always be false. I think you mean to write something more like this: void OnCollisionEnter2D(...


2

error: y has private access in Polygon This simply means, that the y field is private in the Polygon class. Instead of trying to use balls1.y to reach that variable, use setPosition(float x, float y), getX() and getY()


2

First of all, all your physics related stuff should be done in FixedUpdate method and not in Update method. Update is called every frame, while FixedUpdate is called at fixed interval. When you ask Physics movement computation in FixedUpdate Unity will predict the new position in Update until it'll be able to compute the actual position in the next ...


2

This depends on the language. Since you didn't mention language, I am for the moment going to assume either C++ or C# or D or Rust or some similar low-level language (not Java!), because game development. There are zero advantages to keeping x and y as members of Player rather than abstracting out to a Point/Location type. There are many many advantages to ...


2

Code should be like: void OnTriggerEnter(Collider other) { if(other.tag == "setting_object_tag") { Application.LoadLevel(Application.loadedLevel); } } Make the colliding object as trigger and not using gravity as it will not effect surroundings. Application.loadedLevel is the current scene.


1

Ok. After some experiments I ended up replacing the EdgeCollider2D with a PolygonCollider2D. I generated the collider points (taking the width of the wire into account) by computing the Euclidean distance between two consecutive points on the curve (you need to iterate through all the points) and the perpendicular on the distance vector (using the cross ...


1

I found the problem while modifying my code to try out Jon's sugestions. Somehow I added a max distance of 5 to the RayCast. Must have gotten confused with the many overloads or something. It works if I modify the second line like this: if (!Physics.Raycast (transform.position, new Vector3 (0, -50, 0), out hit/*, 5*/)) {


1

As long as you have the position of the moving wall and the size of it, as well as the position of the player and the player size, it's easily doable without using a tile map :) I posted three guides based on shape collision, so check them out: For testing if a point is inside a polygon, use the code I posted below. I wrote this in C# based off of the ...


1

As a general solution, a sphere collider can be imitated with this a simple 3D distance formula equation: Distance = sqrt((x_2 - x_1)**2 + (y_2 - y_1)**2 + (z_2 - z_1)**2) where x_1, y_1, and z_1 are the x, y, and z coordinates of center of the sphere and x_2, y_2, and z_2 are the x, y, and z coordinates of a given vertex. Using this idea, you could simply ...


1

In unity when collision don't work you can fix the problem by following the below steps: 1.Set Collision and Triggers based on game(If game was 2d you should use BoxCollider2D) and check BoxCollider2D trigger Boolean. 2.you should check Rigidbody Component that attached to objects because Collision need physics component(if game was 2d you should use ...



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