collision

Have object detect if completely inside other object JavaScript

断了今生、忘了曾经 提交于 2020-01-05 08:39:22
问题 Hello I'm making a game for my CS class using JavaScript. I know how to ale objects collide with each other in the canvas but I m trying to get an object to detect if it's completely inside another object If (object1.xcoord > object2.xcoord && object1.xcoord + object1.width < object2.xcoord + object2.width && object1.ycoord + object1.height < object2.ycoord +object2.height) { alert("hi") } Note I only need those three sides it doesn't matter to me if object 1 is within top side of object 2

For some reason, colliders collide, and I can fly

余生颓废 提交于 2020-01-05 04:11:14
问题 I am making a small prototype of a Unity 2D game. I have 2 colliders for my character. This helps me because I want my character to be able to wall jump. This means that when I collide with the wall, my collider detection script assumes that I am hitting 2 colliders, and helps me customize animations. //on the ground, change y position as necessary, and if you are pressing up, held = true if (InAirDetection.AirDetect == 1) { position.y += MoveUnitsPerSecond * verticalInput * Time.deltaTime;

What is the Best Second Hash function when using Double Hashing?

佐手、 提交于 2020-01-05 02:55:07
问题 I saw in some of the forums that people used: 7-(key mod 7) or 6-(key mod 6) This is used for computing the second hash function of Double Hashing for any large values of the key. Is there any importance to the usage of that 6(not even a prime no.) or 7? Or is it just to randomly generate some value unlike linear probing and quadratic probing? References: http://www.java2s.com/Code/Java/Collections-Data-Structure/Hashtablewithdoublehashing.htm http://www.cse.unt.edu/~donr/courses/2050

Fast projectiles don't always hit

血红的双手。 提交于 2020-01-04 06:33:53
问题 So for my game, a have a fast moving Bullet object, with a sprite that's 5x5 (roughly). Moving at about a speed of 30, it needs to impact a relatively thin Enemy object with a thickness of only about 5 pixels. At certain regular intervals of distance, the Bullets pass through the enemy without a collision. I think its because the bullet is moving so fast that it happens to "jump" over the enemy, hence the regular intervals. other than increasing the width of the Bullet or Enemy, is there a

Pygame - Collision detection with two CIRCLES

99封情书 提交于 2020-01-03 17:24:13
问题 I'm making a collision detection program where my cursor is a circle with a radius of 20 and should change a value to TRUE when it hits another circle. For testing purposes, I have a stationary circle in the centre of my screen with a radius of 50. I'm able to test whether the cursor circle has hit the stationary circle but it doesn't quite work properly because it's actually testing if it's hitting a square rather than a circle. I'm not very good with maths and I haven't been able to find

Angle that a moving ball will bounce off of an inert ball

眉间皱痕 提交于 2020-01-03 15:49:27
问题 Let there be two balls, one of which is moving about in the Cartesian coordinate plane, while the other is stationary and immobile. At some point, the moving ball collides with the inert ball. Assuming the moving ball is traveling in a straight line, how can one derive the new angle that the moving ball will be propelled given the following information: The moving ball's center coordinates (X0, Y0), radius (R0), and angle of travel before impact (A0) The stationary ball's center coordinates

How would I fix my characters position after hitting a block?

可紊 提交于 2020-01-02 23:14:36
问题 After I hit a platform my character can't move along the x-axis anymore unless you press the left or right keys again. For example, if I jump and I clip the corner of the platform the character doesn't continue moving and I have to either do the jump again or react quickly and press the corresponding key. When I remove the player.friction() in the collision detecting system, if I stop pressing the right key it ends up clipping into the edge of the block, which causes the player to get

how to prevent [circle] body from sliding into 0px gaps between static bodies

点点圈 提交于 2020-01-02 13:18:30
问题 So I have this body that is a circle collider and it has sometimes a big velocity the problem is that the tiled map of the boundaries is made of small tiles and at high velocity the body goes through it here is my config of all bodies: const config = { inertia: Infinity, // do not spin friction: 0, // X*100% stop on hit frictionAir: 0, // X*100% slow on move restitution: 0.5, // bounce X*100% on hit collisionFilter: this.level.getCollisionFilter(), // default collision filter isStatic } ...

How can I test sprite collision in cocos2d?

瘦欲@ 提交于 2020-01-01 12:25:08
问题 How do I start to implement a class for sprite collision? 回答1: As Eric pointed out, CGRectIntersectsRect is the method to test two bounding rects for overlapping. Use the boundingBox method of the CCNode classes to get the correct bounding box for each sprite (or other node). See my answer here: Collision Detection in Cocos2d game? 回答2: I would look into b2ContactListener You can do some searches on that, and you'll easily get some results 回答3: You can also perform very simple collision

How do I check if a simplex contains the origin?

99封情书 提交于 2020-01-01 05:03:30
问题 I am implementing the Gilbert-Johnson-Keerthi algorithm which computes whether two objects are intersecting (ie. colliding). The entry point to my code is the hasCollided function which takes two lists of points and returns True if they are intersecting. I believe I have implemented the paper correctly - however, I still have to implement the contains function. The contains function should determine whether a simplex contains the origin. I am unsure as to how to implement this. How do I