game-physics

Apply Physics2D to 3D Game Objects - Unity3D

烂漫一生 提交于 2019-12-11 05:28:46
问题 Is it possible to use Physics 2D components(rigidbody2d,collider2d..etc) on 3d Game objects. I am planning develop 2 game with some of 3d model. Thanks! 回答1: It is not, however what you can do with rigidbody3d is lock the physics movement and rotation on it. For example, if you only ever wanted it to move along the x and y axis of your game, in the inspector just tick the freeze z movement box for the rigidbody component. 来源: https://stackoverflow.com/questions/27058919/apply-physics2d-to-3d

Ignore physics after collision in unity3d(2d)

和自甴很熟 提交于 2019-12-11 04:23:54
问题 How can I force Unity to not change the speed and direction of objects after collision? I need to get OnCollisionEnter2d event, but I don't need to automatically change speed and direction; I want to do it manually. 回答1: I need to get OnCollisionEnter2d event, but i dont need to automatically change speed and direction, because i want to do it manually If you don't want to affect the Object when it collides with another Object, you need to mark the Collider as Trigger. After this, use the

how to make my player move in diagonal lines and horizontal lines

时光怂恿深爱的人放手 提交于 2019-12-11 04:17:36
问题 i have the following code to make an ellipse move to the left right top and bottom. but now the player can only move in one direction at the time. so if the player moves to the left he cant move to the to the top or bottom. how do i make my code so the player can move both left and right and to the top and the bottom at the same time? any suggestions are appreciated. :) see the code that i have so far: void userInput() { if (keyPressed && (key == 's')) { speedY = 1; println("yes"); } if

Calculating Rigid body Inertia Tensor world coordinates

混江龙づ霸主 提交于 2019-12-11 03:46:50
问题 I'm trying to implement a small rigid body physics simulation, using DirectX to draw my objects and its Math library to take advantage of SIMD calculation (XMMATRIX and XMVECTOR classes). My question is about the Inertia Tensor , I know that using its inverse I can calculate the angular acceleration like so: AngAcc = Inverse(I) * torque and that inertia tensor, in local space, is constant... so I have store its inverse in my RigidBody class with some other members: //'W' suffix means 'world

Determing the direction of face normals consistently?

丶灬走出姿态 提交于 2019-12-11 03:42:29
问题 I'm a newbie to computer graphics so I apologize if some of my language is inexact or the question misses something basic. Is it possible to calculate face normals correctly, given a list of vertices, and a list of faces like this: v1: x_1, y_1, z_1 v2: x_2, y_2, z_2 ... v_n: x_n, y_n, z_n f1: v1,v2,v3 f2: v4,v2,v5 ... f_m: v_j, v_k, v_l Each x_i, y_i , z_i specifies the vertices position in 3d space (but isn't neccesarily a vector) Each f_i contains the indices of the three vertices

2D bouncing formula doesn't work properly

心已入冬 提交于 2019-12-11 02:33:46
问题 I am new to unity, and i am trying to create a bouncing ball, so i've did many researches about bouncing realted physics and i found a formula : Formula: -2*(V dot N)*N + V Where V is the velocity vector and N is the normal of the surface on which the ball will bounce Here is my script : using UnityEngine; using System.Collections; public class BallPhysics : MonoBehaviour { void Start () { rigidbody2D.velocity =new Vector2 (-1,-3); } // Update is called once per frame void Update () { } void

Let an Enemy follow a path with the same speed

£可爱£侵袭症+ 提交于 2019-12-11 01:29:38
问题 I started programming a game in java. I have Enemys and a Player, a basic 2D game, thats to get experience for the first time. Now i wanted the Enemys to follow a path, which i can draw in to a "level editor". I have a JPanel, a mouseMoveListener, and on click the Path2D starts saving the mouseMove Points to a Path2D.Double Object. After that, i implemented the following method to make the enemys following this path: public void forward(){ if(!pathIterator.isDone()){ pathIterator

Line collision in pygame

☆樱花仙子☆ 提交于 2019-12-11 01:27:03
问题 So I am currently working on a 2D platformer game and i have realized a big issue with my collision programming. You see, to find out collisions with the player I just moved the player rect around, then when colliding i pushed the player away by looking at the x and y acceleration on him. The problem is though, when using this method, the player speed can make the player skip over targets he is supposed to collide with because the rect he is supposed to collide with is too small. For example

Verlet integrator + friction

女生的网名这么多〃 提交于 2019-12-10 22:16:13
问题 I have been following "A Verlet based approach for 2D game physics" on Gamedev.net and I have written something similar. The problem I am having is that the boxes slide along the ground too much. How can I add a simple rested state thing where the boxes will have more friction and only slide a tiny bit? 回答1: Just introduce a small, constant acceleration on moving objects that points in the direction opposite to the motion. And make sure it can't actually reverse the motion; if you detect that

Android getX/getY interleaves relative/absolute coordinates

让人想犯罪 __ 提交于 2019-12-10 21:34:20
问题 There are a lot of discussions of how MotionEvent.getX/.getY are "unreliable" (or other terms) and that we should use the Raw versions of these calls to get coordinates. On my Nexus 7, I have discovered that .getX/.getY are reliably returning interleaved absolute and relative coordinates. In other words, say a given ACTION_MOVE event returns absolute coordinates when you call .getX and .getY. The next ACTION_MOVE event will then return relative coordinates on its .getX and .getY calls. This