game-physics

Using a mathematical formula to define player speed

拈花ヽ惹草 提交于 2020-02-23 07:18:08
问题 I'm making simple game in which the player is moved by adding force to him. However, I don't want his acceleration to be constant - I want it to vary depending on the current speed. I made simple acceleration script to do this but it doesn't achieve the desired effect: float acceleration { get { return speed/inversedAcceleration; } } void FixedUpdate () { rb.AddForce(transform.forward * speed); if (speed < maxSpeed) speed += acceleration * Time.deltaTime; } New way that I also tried: float

SpriteKit physics false positive?

徘徊边缘 提交于 2020-02-06 05:50:47
问题 The contact point provided by didBeginContact does not always rest in the paths that define the physics bodies involved in the collision. This behavior is most problematic in cases where the bodies never come into contact (if the circle node is 1px further right, the contact still happens though it is mathematically impossible.) In the image and program below, the rectangle has a width of 100px, but the contact point (shown in the output) is at 101.4550... import SpriteKit class GameScene:

Mouse based aiming Unity3d

北城余情 提交于 2020-01-29 04:14:07
问题 I am making cannonball shooter game. here's a short code where I am calculating the aiming direction. Vector3 mousePos = Input.mousePosition; mousePos.z = thisTransform.position.z - camTransform.position.z; mousePos = mainCamera.ScreenToWorldPoint (mousePos); Vector3 force = mousePos - thisTransform.position; force.z = force.magnitude; This works when both ball and at angle (0,0,0). But when the angle changes, I am not able to shoot at right direction. Suppose both ball and camera are looking

Implementing gravity flipping mechanics using C++ Win32

陌路散爱 提交于 2020-01-25 08:49:06
问题 I'm trying to think of an efficient way implementing gravity flipping mechanics into my C++ Win32 game. Although I'm not very fluent with the language, thats why I'm here to ask. I have: A class which stores the properties of the player (such as position and size, as well as some functions). A Message Router which takes in messages sent from the user (and other sources). These messages include the player inputs. I handle the inputs in the Message Router and then call the functions on the

Is there an upper limit on velocity when using box2d?

坚强是说给别人听的谎言 提交于 2020-01-19 15:40:53
问题 I'm using box2d for physics simulation. I'm moving a circle using arrow keys by applying impulse on the body when ever a key is pressed. Unfortunately, the circle moves excruciatingly slow and doesn't seem to accelerate like a true physical body is supposed to. My world's dimensions are 400x800 pixels. The radius of the circle body is 20f. According to this, the problem can be solved by scaling the circle radius down when creating it and scaling up after getting the body position during

Cocos2d-js: effect on cocos2d-js application running on browser while a move from one application to another application

时光毁灭记忆、已成空白 提交于 2020-01-16 03:24:25
问题 i was running parkour game given on cocos2d website on my browser. everything was working fine, but when i move from my browser to sublime text and returned to my browser, the running player start to show some unexpected behaviour, the player disappeared from its position and and after few second it fall on the ground and then start running again .whenever i move from one application to another it happens. i don't why its happening. could some one tell me how to prevent this from happen? here

how to control the speed of animation, using a Bezier curve?

你。 提交于 2020-01-16 02:50:47
问题 I found formula only for vector coordinates of cubic curve who help in depicts(build vector image). Here it is: B(t) = (1-t)^3*P0 + 3*t*(1-t)^2*P1 + 3*t^2*(1-t)*P2 + t^3*P3 See more at: http://www.ams.org/samplings/feature-column/fcarc-bezier#sthash.85XhcT7H.dpuf This formula returns the coordinates of the vector, but I can not understand how they can influence the speed of the animation, as in http://cubic-bezier.com/#.17,.67,.83,.67. Please, direct me to the right way so that I could

What collision detection method to use with hand drawn surface?

孤街浪徒 提交于 2020-01-15 06:26:42
问题 I have a lunar lander type game. I don't use any physics engines. My lander keeps falling if you do not use thruster and eventually lands on the ground. Ground is hand drawn, it is not a line, more like curve, and the land can be of any configuration or color. How do I properly use collision detection and its results? 回答1: Well it depends on what you want to do. I would recommend one of the following: Use physics engines. They are there for something. You could create different shapes what

How do you calculate the rate of rotation using the accelerometer values in Android for a particular axis

六月ゝ 毕业季﹏ 提交于 2020-01-14 02:47:10
问题 I am developing a simple game which involves a character moving up and down only along the Y axis. Currently I am using the accelerometer readings to change the Y velocity of the character. The game works fine but the biggest problem is that you have to keep the device horizontal in order to play the game properly. What I really want is to change the characters Y velocity only when there is a change in the rate of rotation along the Y axis. I need to be able to translate this rate of change

Modelling clothing in C++ [closed]

大憨熊 提交于 2020-01-12 06:24:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm looking to write a bit of software that will end up drawing a human frame (which can be configured with various parameters), and the plan is to have some sort of clothing placed on the dummy. I've looked at Blender, and OpenGL libraries as well as other rendering and physics engines, I'm not looking for you