game-physics

physics engine - phase order and other general information

六眼飞鱼酱① 提交于 2019-12-02 07:30:23
问题 I want to build my own 2D mini-physics engine, that will include(for now) rigid bodys, and constraints (joints, contacts, springs...). And I've tried to figure out what is the right order of the phases, when I start a timestep, when the the general phases are: Broadphase, Narrow phase(Collision Detection, and Contact generation), Resolution (Constraints Solver), and the Integration - hope you can tell me the right order. I allso have general questions about each phase: Narrow Phase - When I

How to determine which side of a rectangle collides with a circle

≯℡__Kan透↙ 提交于 2019-12-02 07:17:21
问题 Before you point out that there are other answers to this question, i have looked at if not all, most of the other answers to this question or a similar question and i haven't found the solution i require. Basically all i want to be able to do is when the circle/ball collides with a rectangle, i want to determine which side of the rectangle this collision has occured at. I want to find this out so that i can enforce a bit more realistic physics, e.g. if the ball hits the top of the rectangle,

physics engine - phase order and other general information

扶醉桌前 提交于 2019-12-02 04:46:00
I want to build my own 2D mini-physics engine, that will include(for now) rigid bodys, and constraints (joints, contacts, springs...). And I've tried to figure out what is the right order of the phases, when I start a timestep, when the the general phases are: Broadphase, Narrow phase(Collision Detection, and Contact generation), Resolution (Constraints Solver), and the Integration - hope you can tell me the right order. I allso have general questions about each phase: Narrow Phase - When I've found a collision do I need to seperate the bodies after I've found the collision or just apply an

Collision detection of a ball with an arc

二次信任 提交于 2019-12-02 04:28:38
I am making a simple game in which i have a ball and an arc revolving around the center. When user touches the screen the ball moves in the direction of pointer and hits the arc. But i am not able to find any method to detect that collision An image has been attached for better understanding Game image Debug Snapshot.. I have a circle bound around my ball... What i am doing is Detecting the point of intersection of ball center and circle on which arc is >revolving. But i am not able to detect whether the arc was there when ball intersected the circle?? please help...:'( Code for making arc:

Recursive call to buff/unbuff? C# Unity3D

青春壹個敷衍的年華 提交于 2019-12-02 03:08:35
My goal is to make a single collision detection that will decrease the movement speed of the object it collided with for a specific duration. What I tried so far: //Class that detects the collision if (other.gameObject.tag == "enemy") { EnemyMovement enemyMove = other.GetComponent <EnemyMovement> (); if (enemyMove.slowMove != 1) { return; } enemyMove.Slow (2, 0.5f, true); //.... //Class that handles the Enemy-Movement //The slowfactor gets multiplied with the Vector3 that handles the movementspeed of the Character void FixedUpdate () { Movement(); } void Movement() { gegnerRigid.MovePosition

Make an object move towards another objects position

試著忘記壹切 提交于 2019-12-02 02:12:39
问题 What I have currently is two objects that can be played though nav keys and the other one with wasd. The point is to get the 3rd object and score a point, and it randoms a new pos after catching it, which works. Now... I want the npc2 to not longer be controlled by human, and create a method for it to move on its own TOWARDS the scoring object. How would I possibly do to achieve this? Im new to c# :) FORM.cs below using System; using System.Collections.Generic; using System.ComponentModel;

Smooth fly movement like flappy bird or jet pack joy ride with gravity and Accelaration

纵然是瞬间 提交于 2019-12-01 21:07:46
I am developing a simple game in which a character fly when you tap/click the screen. keep tapping the character will fly (some what similar to flappy bird and jet pack). However the movement is not smooth at all, as of jet pack. Here is sample of my code. Varaible Initilization maxSpeedLimit = spriteHeight/10; speed = maxSpeedLimit/2; //half of the max speed touch event public void onTapOrClick(int action) { if (action == UP) { sprite.up= true; } else { sprite.up = false; } } Sprite update called from game loop public void update() { if (up) { y -= speed; //fly up } else { y += speed;// fly

Bouncing a ball off a surface

倖福魔咒の 提交于 2019-12-01 20:29:08
问题 I'm currently in the middle of writing a game like Breakout, and I was wondering how I could properly bounce a ball off a surface. I went with the naive way of rotating the velocity by 90 degrees, which was: [vx, vy] -> [-vy, vx] Which (unsurprisingly) didn't work so well. If I know the position and veocity of the ball, as well as the point the ball would hit (but is going to instead bounce off of) how can I bounce it off that point? Constraints: I'm using integer math (No FP anywhere) All my

Bouncing a ball off a surface

帅比萌擦擦* 提交于 2019-12-01 19:46:36
I'm currently in the middle of writing a game like Breakout, and I was wondering how I could properly bounce a ball off a surface. I went with the naive way of rotating the velocity by 90 degrees, which was: [vx, vy] -> [-vy, vx] Which (unsurprisingly) didn't work so well. If I know the position and veocity of the ball, as well as the point the ball would hit (but is going to instead bounce off of) how can I bounce it off that point? Constraints: I'm using integer math (No FP anywhere) All my surfaces are simple flat surfaces (Vertical, horizontal, or a block) I only want to bounce off in a 90

Javascript ball collision

孤者浪人 提交于 2019-12-01 14:00:20
I am trying to create a simple javascript game with simple physics. I can determine when 2 balls are colliding but I have having problems with handling the collision. Does anyone know of any useful tutorials on this? I've been searching the internet for a couple days but can't seem to find anything. In the UK, this would be A-level maths, so not too advanced. I think the phrase you need is " elastic collision ". That page has some of the formulae you need. Physics for JavaScript Games, Animation, and Simulations with HTML5 Canvas is a Book all about modeling Physics simulations in JavaScript.