game-physics

Ray casting on a plane geometry only works from on direction

心不动则不痛 提交于 2019-12-25 16:46:52
问题 I'm using plane geometries as walls in a game. I'm using ray caster to provide the player from moving through them. The problem is that planes only works one way. When the player comes from the "front" side it works but when it comes from behind it moves through. Cube and sphere geometries works from any directions so my ray caster function seems to do the job. I have set material to be double sided but it doesn't help. Does any one know about this issue? How can I make the plane using both

How to make a character move while key is held down

ぃ、小莉子 提交于 2019-12-25 07:33:32
问题 I'm trying to create a "player" - black square - which moves when you hold down WASD. I tried looking around here, on google and on youtube on how to make this work, but every solution I've tried has the same problem: instead of moving it while I hold down the key, I have to tap the key constantly to make it move in small bits. I've no clue what I'm doing wrong. Here's the code (using python 3.3 - pygame 1.9): import pygame from pygame.locals import * from pygame.time import * import sys

AS3 Character jumping/falling problems

与世无争的帅哥 提交于 2019-12-25 06:59:32
问题 I am having problems with getting the character to jump/fail when the up arrow is pressed. I'm trying to make it so when the up arrow key is pressed once it will jump a certain height then fall. Here is my movement code: public var gravity:int = 2; public function fireboyMovement(e:KeyboardEvent):void { if (e.keyCode == 37) //right { fireboy1.x = fireboy1.x -5; checkBorder() } else if (e.keyCode == 39) //left { fireboy1.x = fireboy1.x +5; checkBorder() } if (e.keyCode == 38) //up { fireboy1.y

Isometric rendering without tiles, is that goal reachable?

谁说胖子不能爱 提交于 2019-12-25 04:27:39
问题 I'm creating a 2d game in HTML5 canvas. It's an isometric world, so actually it's also 3d. You always see that isometric games use tiles, and I think the reason is just for the depth logic. My goal is to create the game without using a tile system. Each item can be placed by the user, so item locations like walls, trees, etc., have variable positions. The positions are isometric x, y, z coordinates. If the game was just tiled, you could determine a fixed tile area for each item. (I mean: a

applyForce is not smooth

不想你离开。 提交于 2019-12-24 14:16:55
问题 Hopefully someone can help. I have been pulling my hair out on this one! Below is some of the control pad code from my Sprite Kit game which uses applyForce to move the hero ship. I like how the controls and movement feel, its got some nice drift, etc... However I have inconsistent results on the animation/movement it produces. Sometimes (about half the time) the animation is perfectly smooth and looks correct. The rest of the time the ship movement animation stutters at different intensities

Pacman java movement issues

不羁的心 提交于 2019-12-24 12:56:27
问题 I have faced a little problem with my pacman movement that i'm working on right now. I can't seem to find a way to make the movement similar to the originated pacman movement. In order to explain how i want it to move, i have uploaded this picture. As it stand now, i have made the collision working between the yellow rectangle and the blue walls. The problem is when i move to the left as in the picture and i click the up arrow, it should not stop, but continue to move and then go up when

How to return sum of two normalized values in a normalized output

江枫思渺然 提交于 2019-12-24 11:29:44
问题 I need a function that takes a and b both in [0..1] range, and adds a and b and returns the output in [0..1] range, when the sum is above 1 it wraps to zero like mod function. I tried this but it doesn't work: function shift(a, b) { return (a + b) % 1; } For example for a = 1 and b = 0, it returns 0 but I want it to return 1. 回答1: I think the best you can do is something like: function normalize(a, b) { let r = (a + b); return r === 1 ? 1 : r % 1; } This will return 0 when the sum is exactly

Whats the best way to do character animations with Box2D?

北战南征 提交于 2019-12-23 17:41:57
问题 I am developing a 2D, underwater, action-RPG for Android, using Box2D as the physics engine, mainly for collision detection, collision response and movement of in-game characters within an environment comprised of walls, rocks, and other creatures. I have tried two different approaches for implementing character animations using Box2D, and have found issues with both. As I'm new to Box2D and physics engines, I would appreciate a recommendation on how these things should best be done. An

The time-corrected Verlet numerical integration formula

我只是一个虾纸丫 提交于 2019-12-23 09:47:49
问题 There is a commonly used verlet-integration formula on the web by Johnathan Dummer, called Time-Corrected Verlet. However I've read several forum posts, that people get weird or unexpected results with it in certain conditions. Formula by Johnathan Dummer: x1 = x + (x – x0) * dt / dt0 + a * dt^2 There is also a stackoverflow answer, which states that Dummer's time-corrected formula is broken and the poster presents his own derivation as the correct one. Suggested correct formula by a

Algorithm 3d orbiting camera control with mouse drag

谁说胖子不能爱 提交于 2019-12-23 04:01:49
问题 Please help, I couldn't find detailed explanation about this which is not language specific and not library dependent, because I want to control the math myself for some reason. How to create orbiting camera control with mouse, like middle-click drag in Google SketchUp ? * In Google SketchUp, the camera can move circularly orbiting imaginary object in the middle of the plane ( not always 0,0,0) by dragging the mouse. It can orbit horizontally, vertically, even diagonally, all directions. 回答1: