collision-detection

Properly attach to a GameObject after collision?

ε祈祈猫儿з 提交于 2019-12-08 19:18:58
问题 How can I properly make a GameObject attach (or "stick") to another GameObject after collision? The problem: I want the GameObject to attach after collision even if it is changing scale. "Attach on collision" code: protected Transform stuckTo = null; protected Vector3 offset = Vector3.zero; public void LateUpdate() { if (stuckTo != null) transform.position = stuckTo.position - offset; } void OnCollisionEnter(Collision col) { rb = GetComponent<Rigidbody>(); rb.isKinematic = true; if(stuckTo ==

Collision Detection and Collision Response

做~自己de王妃 提交于 2019-12-08 16:43:49
问题 I've been trying my hand at representing a few moving/rotating objects using androids Opengl. Now I'd like to allow them to collide and respond realistically. Researching the issue, I can find many resources that advise me on ways to determine whether two 3d shapes are colliding in the current frame (or whether they'll be colliding in the next frame). However, I'm having trouble finding resources describing how to get information about the collision that has occurred. For example, using

Action in collision detection (CGRectIntersectsRect)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 14:06:57
问题 I have two images. You have to use a acceleremoter to move a man and avoid a big spike. Here is my .h coding: IBOutlet UIImageView *rect1; IBOutlet UIImageView *rect2; Here is my .m: bool CGRectIntersectsRect ( CGRect rect1, CGRect rect2 ); I have connected everything in the nib file and I know nothing would happen because there was no error. I need these two things to collide and then generate an end screen. BUT HOW do I put an action in. THANKS! .m #import "GameScreen.h" @implementation

When projectile hits two “monsters” the didBeginContact method crashes. I know why but i don't know how to avoid it

◇◆丶佛笑我妖孽 提交于 2019-12-08 13:43:00
问题 So I have this code from the tutorial: func didBeginContact(contact: SKPhysicsContact) { // 1 var firstBody: SKPhysicsBody? var secondBody: SKPhysicsBody? var body: SKPhysicsBody //contact.bodyB.node!.physicsBody!.allContactedBodies().count if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask { firstBody = contact.bodyA secondBody = contact.bodyB println("1 = A, 2 = B") } else { firstBody = contact.bodyB secondBody = contact.bodyA println("2 = A, 1 = B") } // 2 if ((firstBody!

Collision detection leading to color detection? [duplicate]

和自甴很熟 提交于 2019-12-08 09:34:32
问题 This question already exists : Do an SKAction if the colors of two sprites aren't the same? [duplicate] Closed 3 years ago . How can I check if, when I collide with an SKSpriteNode in the middle of two rectangles with a ball, the ball and the two rectangles are the same color? For example, if my two rectangles are red, and my ball is blue, I want it to detect that the colors of my rectangle and the ball are different. If they are the same color, then I don't want anything to happen. If they

Cocos2dx Box2D - b2body GetUserData always returns null

我的未来我决定 提交于 2019-12-08 09:09:06
问题 am having one car and one bike object. at the time of collison detction. i need to get which(Car or bike) is colliding with wall. for that am using body->getuserdata . but it always returns null. am confuse d that why am getting null. were am wrong? i refer this link but same as i did. not useful. Code for car:- sprintf(temp,CAR_BODY_CAR_PLIST); m_Texture[2] = new TextureObject(temp,spritesheet1,1,true,kTexture2DPixelFormat_Default,2); // add cart // b2BodyDef bodyDef; b2FixtureDef fixtureDef

pygame level changing on collision

你。 提交于 2019-12-08 09:07:25
问题 I need to make a level change when my player object collides with ExitBock object. My player object (half comments are in my language, but comments that are there where I need for help is translated): class Player(Entity): def __init__(self, x, y): Entity.__init__(self) self.xvel = 0 self.yvel = 0 self.onGround = False self.image = Surface = right_standing self.rect = self.image.get_rect() def update(self, up, down, left, right, running, platforms): a = 0 if up: # Pasokti tik ant zemes if

Android Libgdx and collision detection

大兔子大兔子 提交于 2019-12-08 06:42:45
问题 For my android game I use Libgdx and I detect the collision between Bob (Omino) and Plant (Pianta) with this code that works fine : Assets.class pianta = new Animation(0.5f,new TextureRegion(items, 160, 384, 64, 96), new TextureRegion(items, 224, 384, 64, 96)); Pianta.class public class Pianta extends GameObject { public static final float PIANTA_WIDTH = 2; public static final float PIANTA_HEIGHT = 3; public static float stateTime; public Pianta(float x, float y) { super(x, y, PIANTA_WIDTH,

Collision and bounce detection from array of points

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 05:58:04
问题 I have an array of points that I will use to generate a closed polygonal fence on the outside of a game stage (2D). I wish to have collision detection between this fence and a bouncing ball-like object on the inside. Additionally, I would like to be able to arbitrarily add/remove/redraw the fence in realtime and have the collision detection still operate realistically. I have considered drawing a Sprite/Shape from the points and doing a HitTest at each frame to check whether to bounce or not.

Javascript Collision Detection between circle and polygon?

爷,独闯天下 提交于 2019-12-08 05:57:11
问题 I'm unsure how to go about defining the area for a collision detection function when I have a polygon that looks like: ______ / _____| / / / / --- I draw the polygon using lineTo() a few times before fill/stroke call so I know the x,y co-ords of all the points. Currently I just check if the ball is beyond certain areas of points: if(tmpParticle.y <= platformBottom) { if(tmpParticle.x < leftPipe_middleX || tmpParticle.x > rightPipe_middleX) { tmpParticle = particleCollision(tmpParticle,