Search Results

Search found 1703 results on 69 pages for 'intrusion detection'.

Page 20/69 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • 2D Collision in Canvas - Balls Overlapping When Velocity is High

    - by kushsolitary
    I am doing a simple experiment in canvas using Javascript in which some balls will be thrown on the screen with some initial velocity and then they will bounce on colliding with each other or with the walls. I managed to do the collision with walls perfectly but now the problem is with the collision with other balls. I am using the following code for it: //Check collision between two bodies function collides(b1, b2) { //Find the distance between their mid-points var dx = b1.x - b2.x, dy = b1.y - b2.y, dist = Math.round(Math.sqrt(dx*dx + dy*dy)); //Check if it is a collision if(dist <= (b1.r + b2.r)) { //Calculate the angles var angle = Math.atan2(dy, dx), sin = Math.sin(angle), cos = Math.cos(angle); //Calculate the old velocity components var v1x = b1.vx * cos, v2x = b2.vx * cos, v1y = b1.vy * sin, v2y = b2.vy * sin; //Calculate the new velocity components var vel1x = ((b1.m - b2.m) / (b1.m + b2.m)) * v1x + (2 * b2.m / (b1.m + b2.m)) * v2x, vel2x = (2 * b1.m / (b1.m + b2.m)) * v1x + ((b2.m - b1.m) / (b2.m + b1.m)) * v2x, vel1y = v1y, vel2y = v2y; //Set the new velocities b1.vx = vel1x; b2.vx = vel2x; b1.vy = vel1y; b2.vy = vel2y; } } You can see the experiment here. The problem is, some balls overlap each other and stick together while some of them rebound perfectly. I don't know what is causing this issue. Here's my balls object if that matters: function Ball() { //Random Positions this.x = 50 + Math.random() * W; this.y = 50 + Math.random() * H; //Random radii this.r = 15 + Math.random() * 30; this.m = this.r; //Random velocity components this.vx = 1 + Math.random() * 4; this.vy = 1 + Math.random() * 4; //Random shade of grey color this.c = Math.round(Math.random() * 200); this.draw = function() { ctx.beginPath(); ctx.fillStyle = "rgb(" + this.c + ", " + this.c + ", " + this.c + ")"; ctx.arc(this.x, this.y, this.r, 0, Math.PI*2, false); ctx.fill(); ctx.closePath(); } }

    Read the article

  • Checking for collisions on a 3D heightmap

    - by Piku
    I have a 3D heightmap drawn using OpenGL (which isn't important). It's represented by a 2D array of height data. To draw this I go through the array using each point as a vertex. Three vertices are wound together to form a triangle, two triangles to make a quad. To stop the whole mesh being tiny I scale this by a certain amount called 'gridsize'. This produces a fairly nice and lumpy, angular terrain kind of similar to something you'd see in old Atari/Amiga or DOS '3D' games (think Virus/Zarch on the Atari ST). I'm now trying to work out how to do collision with the terrain, testing to see if the player is about to collide with a piece of scenery sticking upwards or fall into a hole. At the moment I am simply dividing the player's co-ordinates by the gridsize to find which vertex the player is on top of and it works well when the player is exactly over the corner of a triangle piece of terrain. However... How can I make it more accurate for the bits between the vertices? I get confused since they don't exist in my heightmap data, they're a product of the GPU trying to draw a triangle between three points. I can calculate the height of the point closest to the player, but not the space between them. I.e if the player is hovering over the centre of one of these 'quads', rather than over the corner vertex of one, how do I work out the height of the terrain below them? Later on I may want the player to slide down the slopes in the terrain.

    Read the article

  • Grid based collision - How many cells?

    - by Fibericon
    The game I'm creating is a bullet hell game, so there can be quite a few objects on the screen at any given time. It probably maxes out at about 40 enemies and 200 or so bullets. That being said, I'm splitting up the playing field into a grid for my collision checking. Right now, it's only 8 cells. How many would be optimal? I'm worried that if I use too many, I'll be wasting CPU power. My main concern is processing power, to make the game run smoothly. RAM is not a big concern for me.

    Read the article

  • Collision with half of a semi-circle

    - by heitortsergent
    I am trying to port a game I made using Flash/AS3, to the Windows Phone using C#/XNA 4.0. You can see it here: http://goo.gl/gzFiE In the flash version I used a pixel-perfect collision between meteors (it's a rectangle, and usually rotated) that spawn outside the screen, and move towards the center, and a shield in the center of the screen(which is half of a semi-circle, also rotated by the player), which made the meteor bounce back in the opposite direction it came from, when they collided. My goal now is to make the meteors bounce in different angles, depending on the position it collides with the shield (much like Pong, hitting the borders causes a change in the ball's angle). So, these are the 3 options I thought of: Pixel-perfect collision (Microsoft has a sample) , but then I wouldn't know how to change the meteor angle after the collision 3 BoundingCircle's to represent the half semi-circle shield, but then I would have to somehow move them as I rotate the shield. Farseer Physics. I could make a shape composed of 3 lines, and use that as the collision object for the shield. Is there any other way besides those? Which would be the best way to do it(it's aimed towards mobile devices, so pixel-perfect is probably not a good choice)? Most of the time there's always a easier/better way than what we think of...

    Read the article

  • How to detect collisions between sprite and a user generated shape of some sort?

    - by Huwell
    How to detect a collision between a sprite and a user generated shape of some sort. For example. There are some objects on the screen. The user takes their finger and draws an circle shape around a object (The selection rule is painting circle around the sprite, but the painting shapes may be various). I need to detect which object selected, which just like: (demo images) http://i52.tinypic.com/28h0t1g.png

    Read the article

  • Private domain purchase with paypal: how to prevent fraud?

    - by whamsicore
    I am finally going to buy a domain I have been looking at. The domain owner wants me to give him my Godaddy account information and send him the payment via Paypal gift, so that there will be no extra charges. Should this cause suspicion? Does Paypal offer any kind of fraud protection? What is the best way to protect myself from fraud in this situation, without the need for escrow services, such as escrow.com? Any advice welcomed. Thanks.

    Read the article

  • OpenGL Get Rotated X and Y of quad

    - by matejkramny
    I am developing a game in 2D using LWJGL library. So far I have a rotating box. I have done basic Rectangle collision, but it doesn't work for rotated rectangles. Does OpenGL have a function that returns the vertices of rotated rectangle? Or is there another way of doing this using trigonometry? I had researched how to do this and everything I found was using some matrix that I don't understand so I am asking if there is another way of doing this. For clarification, I am trying to find out the true (rotated) X,Y of each point of the rectangle. Let's say, the first point of a rectangle (top,left) has x=10 y=10.. Width and height is 100 pixels. When I rotate the rectangle using glRotatef() the x and y stay the same. The rotation is happening inside OpenGL. I need to extract the x,y of the rectangle so I can detect collisions properly.

    Read the article

  • How to make an object move again after being stopped by collision in Unity?

    - by Matthew Underwood
    I have a player object which position is always centered on the main camera's viewport. This object has a Rigidbody 2D, a box and circle collider. The player moves around a level, the level has a polygon collider attached. I move the camera until the object hits against the collider, which stops the movement of the camera by setting its speed to 0. The problem happens when I want to move the camera / player object away from the collider. As the speed is already at 0, it cannot move away from the collider. The script attached to the player object, checks for collisions and applies the speed to 0 on the main camera's test script. using UnityEngine; using System.Collections; public class move : MonoBehaviour { public float speed; public test testing; // Use this for initialization void Start () { speed = 10F; testing = Camera.main.GetComponent<test>(); } // Update is called once per frame void FixedUpdate () { Vector3 p = Camera.main.ViewportToWorldPoint(new Vector3(0.5F, 0.5F, Camera.main.nearClipPlane)); transform.position = new Vector3(p.x, p.y, -1); } void OnCollisionEnter2D(Collision2D col) { testing.speed = 0; } void OnCollisionExit2D(Collision2D col) { testing.speed = 10F; } } This is the script attached to the main camera; just a simple script that changes the camera's position. using UnityEngine; using System.Collections; public class test : MonoBehaviour { public float speed; public float translationY; public float translationX; // Use this for initialization void Start () { speed = 10F; } void FixedUpdate () { translationY = Input.GetAxis("Vertical") * speed * Time.deltaTime; translationX = Input.GetAxis("Horizontal") * speed * Time.deltaTime; transform.Translate(translationX, translationY, 0); } } The player object isn't kinematic and is a fixed angle, the colliders aren't triggers and the polygon collider isn't a trigger either. The player is the red square, the collider is the pink area. -- EDIT -- From the latest change the collider set up for the player So if the X speed was disabled. It wouldnt move into the side of the polygon colider which is good, but yet you couldnt move away from it. And moving down would move inside the colider.

    Read the article

  • How could I implement 3D player collision with rotation in LWJGL?

    - by Tinfoilboy
    I have a problem with my current collision implementation. Currently for player collision, I just use an AABB where I check if another AABB is in the way of the player, as shown in this code. (The code below is a sample of checking for collisions in the Z axis) for (int z = (int) (this.position.getZ()); z > this.position.getZ() - moveSpeed - boundingBoxDepth; z--) { // The maximum Z you can get. int maxZ = (int) (this.position.getZ() - moveSpeed - boundingBoxDepth) + 1; AxisAlignedBoundingBox aabb = WarmupWeekend.getInstance().currentLevel.getAxisAlignedBoundingBoxAt(new Vector3f(this.position.getX(), this.position.getY(), z)); AxisAlignedBoundingBox potentialCameraBB = new AxisAlignedBoundingBox(this, "collider", new Vector3f(this.position.getX(), this.position.getY(), z), boundingBoxWidth, boundingBoxHeight, boundingBoxDepth); if (aabb != null) { if (potentialCameraBB.colliding(aabb) && aabb.COLLIDER_TYPE.equalsIgnoreCase("collider")) { break; } else if (!potentialCameraBB.colliding(aabb) && z == maxZ) { if (this.grounded) { playFootstep(); } this.position.z -= moveSpeed; break; } } else if (z == maxZ) { if (this.grounded) { playFootstep(); } this.position.z -= moveSpeed; break; } } Now, when I tried to implement rotation to this method, everything broke. I'm wondering how I could implement rotation to this block (and as all other checks in each axis are the same) and others. Thanks in advance.

    Read the article

  • jBullet Collision/Physics not working as expected

    - by Kenneth Bray
    Below is the code for one of my objects in the game I am creating (yes although this is a cube, I am not making anything remotely like MineCraft), and my issue is I while the cube will display and is does follow the physics if the cube falls, it does not interact with any other objects in the game. If I was to have multiple cubes in screen at once they all just sit there, or shoot off in all directions never stopping. Anyway, I am new to jBullet, and any help would be appreciated. // Constructor public Cube(float pX, float pY, float pZ, float pSize) { posX = pX; posY = pY; posZ = pZ; size = pSize; rotX = 0; rotY = 0; rotZ = 0; // physics stuff fallMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(posX, posY, posZ), 1))); fallRigidBodyCI = new RigidBodyConstructionInfo(mass, fallMotionState, fallShape, fallInertia); fallRigidBody = new RigidBody(fallRigidBodyCI); }

    Read the article

  • Collision Systems Implementation

    - by hrr4
    Just curious what might be a good way to implement a decent collision system. As a class inherited by a base Entity class? Currently I'm stuck and could just use a couple better ideas than my own. Any help is appreciated! Edit: Sorry, it's 2D Collisioning but honestly, I'm not looking for specific collision methods. I'm looking more about the lines of implementation. Just curious of some of the common methods of how to implement collision systems such as: Should the entire collision system be it's own class? What, if anything, should be inheritable? These are some of my questions. Sorry for the confusion.

    Read the article

  • I need help with specific types of movement.

    - by IronGiraffe
    I'm adding movable crates to my game and I need some help with my movement code. The way I've set up my movement code the crate's X and Y are moved according to a vector2 unless it hits a wall. Here's the movement code: if (frameCount % (delay / 2) == 0) { for (int i = 0; i < Math.Abs(cSpeed.X); i++) { if (!Level.PlayerHit(new Rectangle(crateBounds.X + (Math.Sign(cSpeed.X) * 32), crateBounds.Y, crateBounds.Width, crateBounds.Height))) { if (!Level.CollideTiles(crateBounds.X + (Math.Sign(cSpeed.X) * 32), crateBounds.Y, crateBounds.Width, crateBounds.Height)) { if (cSpeed.X != 0) { crateBounds.X += Math.Sign(cSpeed.X); } else { Equalize(2); } } else { cSpeed.X = 0f; } } else { if (!Level.CollideTiles(crateBounds.X - (Math.Sign(cSpeed.X) * 32), crateBounds.Y, crateBounds.Width, crateBounds.Height)) { if (cSpeed.X != 0) { crateBounds.X -= Math.Sign(cSpeed.X); } else { Equalize(2); } } else { cSpeed.X = 0f; } } } for (int i = 0; i < Math.Abs(cSpeed.Y); i++) { if (!Level.PlayerHit(new Rectangle(crateBounds.X, crateBounds.Y + Math.Sign(cSpeed.Y), crateBounds.Width, crateBounds.Height))) { if (!Level.CollideTiles(crateBounds.X, crateBounds.Y + Math.Sign(cSpeed.Y), crateBounds.Width, crateBounds.Height)) { crateBounds.Y += Math.Sign(cSpeed.Y); } else { cSpeed.Y = 0f; } } else { if (!Level.CollideTiles(crateBounds.X, crateBounds.Y - Math.Sign(cSpeed.Y), crateBounds.Width, crateBounds.Height)) { crateBounds.Y -= Math.Sign(cSpeed.Y); } else { cSpeed.Y = 0f; } } } } The frameCount and delay variables just slow down the movement somewhat. Anyway, I've added a tool to my game that acts as a gravity well (drawing objects into it's center; the closer they get to the center the faster they go) and what I'm trying to do is make it so that the crate will bounce off the player (and vice versa) when they collide. Thus far, my code only keeps the crate and player from getting stuck inside each other (the player can still get stuck under the crate, but I'll fix that later.) So what I'd like to know is how I can best make the crate bounce off the player. The other movement problem I'm having is related to another tool which allows the player to pick up crates and move around with them. The problem is that the crate's movement while being carried isn't tied to the movement script (it moves the crate itself, instead of adding to speed), which makes the crate go through walls and such. I know what I have to do: make the crate's speed match the player's speed while the player is holding it, but I need the crate to snap to a certain position (just in front of the player) when the player grabs it and it needs to switch to another position (just in front of the player on the other side) when they player faces the other direction while holding it. What would be the best way to make it switch places while keeping all the movement tied to the speed vector?

    Read the article

  • how to solve ArrayList outOfBoundsExeption?

    - by iQue
    Im getting: 09-02 17:15:39.140: E/AndroidRuntime(533): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1 09-02 17:15:39.140: E/AndroidRuntime(533): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) when Im killing enemies using this method: private void checkCollision() { Rect h1 = happy.getBounds(); for (int i = 0; i < enemies.size(); i++) { for (int j = 0; j < bullets.size(); j++) { Rect b1 = bullets.get(j).getBounds(); Rect e1 = enemies.get(i).getBounds(); if (b1.intersect(e1)) { enemies.get(i).damageHP(5); bullets.remove(j); Log.d("TAG", "HERE: LOLTHEYTOUCHED"); } if (h1.intersect(e1)){ happy.damageHP(5); } if(enemies.get(i).getHP() <= 0){ enemies.remove(i); } if(happy.getHP() <= 0){ //end-screen !!!!!!! } } } } using this ArrayList: private ArrayList<Enemy> enemies = new ArrayList<Enemy>(); and adding to array like this: public void createEnemies() { Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.female); if (enemyCounter < 24) { enemies.add(new Enemy(bmp, this, controls)); } enemyCounter++; } I dont really understand what the problem is, Ive been looking around for a while but cant really find anything that helps me. If you know or if you can link me someplace where they have a solution for a similar problem Ill be a very happy camper! Thanks for ur time.

    Read the article

  • Moving the jBullet collision body to with the player object

    - by Kenneth Bray
    I am trying to update the location of the rigid body for a player class, as my player moves around I would like the collision body to also move with the player object (currently represented as a cube). Below is my current update method for when I want to update the xyz coords, but I am pretty sure I am not able to update the origin coords? : public void Update(float pX, float pY, float pZ) { posX = pX; posY = pY; posZ = pZ; //update the playerCube transform for the rigid body cubeTransform.origin.x = posX; cubeTransform.origin.y = posY; cubeTransform.origin.z = posZ; cubeRigidBody.getMotionState().setWorldTransform(cubeTransform); processTransformMatrix(cubeTransform); } I do not have rotation updated, as I do not actually want/need the player body to rotate at all currently. However, in the final game this will me put in place.

    Read the article

  • Adding delay between damage

    - by iQue
    I have a bunch of enemies chasing my main-character, and if they intersect I want them to damage him and that's all good. The problem is that right now they damage him as long as they stand around him, every frame! and since it gets called every frame my character's HP reaches 0 almost instantly. I've tried adding delay and I've tried a timertask, but can't get it to work. This is the code I use to check for intersection: private void checkCollision(Canvas canvas) { synchronized (getHolder()) { Rect h1 = happy.getBounds(); for (int i = 0; i < enemies.size(); i++) { for (int j = 0; j < bullets.size(); j++) { Rect b1 = bullets.get(j).getBounds(); Rect e1 = enemies.get(i).getBounds(); if (b1.intersect(e1)) { enemies.get(i).damageHP(5); bullets.remove(j); } if(e1.intersect(h1)){ happy.damageHP(5); // this is the statement that needs some sort of delay, I want them to damage him every 2 seconds they intersect him. } if(enemies.get(i).getHP() <= 0){ enemies.get(i).death(canvas, enemies); score.incScore(5); break; } if(happy.getHP() <= 0){ score.incScore(-50); //end-screen } } } } } If anyone knows the logic to do this please do tell.

    Read the article

  • Adding a small slide when player releases left/right key

    - by Dave
    the aim is for the player object to slow down and stop instead of just stopping dead. The following codes works ok when the player is not jumping, but gets stuck in an object if the player is in the air when they do it. Left Key released event: if hsp = 0 exit; hspeed = -3; friction = 0.20; if obj_Player.hspeed = 0 { hspeed = 0; } Right key released event: if hsp = 0 exit; hspeed = +3; friction = 0.20; if obj_Player.hspeed = 0 { hspeed = 0; } and here's the horizontal collision code for interest: if (place_meeting(x+hsp,y,obj_bound)) { while(!place_meeting(x+sign(hsp),y,obj_bound)) { x += sign(hsp); } hsp = 0; } x += hsp; Any help would be much appreciated. Thanks.

    Read the article

  • How does a collison engine work?

    - by JXPheonix
    Original question: Click me How exactly does a collision engine work? This is an extremely broad question. What code keeps things bouncing against each other, what code makes the player walk into a wall instead of walk through the wall? How does the code constantly refresh the players position and objects position to keep gravity and collision working as it should? If you don't know what a collision engine is, basically it's generally used in platformer games to make the player acutally hit walls and the like. There's the 2d type and the 3d type, but they all accomplish the same thing: collision. So, what keeps a collision engine ticking?

    Read the article

  • Normal vector of a face loaded from an FBX model during collision?

    - by Corey Ogburn
    I'm loading a simple 6 sided cube from a UV-mapped FBX model and I'm using a BoundingBox to test for collisions. Once I determine there's a collision, I want to use the normal vector of the collided surface to correct the movement of whatever collided with the cube. I suppose this is a two-part question: 1) How can I determine which face of the cube was collided with in a collision? 2) How can I get the normal vector of that surface?

    Read the article

  • 3D RTS pathfinding

    - by xcrypt
    I understand the A* algorithm, but I have some trouble doing it in 3D to suit the needs of my RTS Basically, in the game I'm making, there will be agents with different sizes of OBB collision boxes. I can use steering behaviours for avoiding other agents, so I don't need complete dynamic pathfinding. However, there is a problem because different agents have different collision geometry, and structures can be placed in almost any place. This means that there might be a gap between two structures where some agents can go through and some can't. A solution I have found to this problem is to do a sweep of the collision geometry of the agent from start node of the edge the pf algorithm is currently testing, to the end node of that edge. But this is probably a bit overkill since every edge the algorithm tests would also have to create and test with a collision geometry sweep. What are some reasonable approaches to this problem? I should mention that I'd prefer not to use navmeshes, I prefer waypoints because my entire system is based on it atm.

    Read the article

  • 2D fighting bounding boxes

    - by user36420
    I'm prototyping a 2D platformer/brawler game for uni and I'm having some trouble with creating collision/bounding boxes. This is most likely going to end up on a Vita so I do have some library constraints as well as performance implications. None of this has yet been implemented but is all theory. My idea was to have the artist create a sprite sheet for the character animation and then a second identical sprite sheet with the corresponding collisions in a solid colour (e.g green for where the character can be hit and red for dealing damage, near the foot if kicking etc.) With this, I would then parse the collision sheet and generate the various collisions required storing them in the character model. This is the point I feel would be most inefficient. While I think this is a possible solution, I was wondering if there was a more standard way of doing this or a more efficient way as I feel this would have severe performance problems.

    Read the article

  • Who should respond to collision: Unit or projectile?

    - by aleguna
    In an RTS if a projectile hits a unit. Who should handle the collision? If projectile handles the collision, it must be aware of all possible types of units, to know what damage to inflict. For example a bullet will likely kill a human, but it will do nothing to a tank. The same goes if unit handles a collision. So either way one of them should be aware of all possible types of the other. Of course the 'true' way would be to do full physics simulation, but that's not an option for an RTS with 1000s of units and projectiles... So what are the common practicies in this regards?

    Read the article

  • How to get distance from point to line with distinction between side of line?

    - by tesselode
    I'm making a 2d racing game. I'm taking the nice standard approach of having a set of points defining the center of the track and detecting whether the car is off the track by detecting its distance from the nearest point. The nicest way I've found of doing this is using the formula: d = |Am + Bn + C| / sqrt(A^2 + B^2) Unfortunately, to have proper collision resolution, I need to know which side of the line the car is hitting, but I can't do that with this formula because it only returns positive numbers. So my question is: is there a formula that will give me positive or negative numbers based on which side of the line the point is on? Can I just get rid of the absolute value in the formula or do I need to do something else?

    Read the article

  • 3D collision physics. Response when hitting wall, floor or roof

    - by GlamCasvaluir
    I am having problem with the most basic physic response when the player collide with static wall, floor or roof. I have a simple 3D maze, true means solid while false means air: bool bMap[100][100][100]; The player is a sphere. I have keys for moving x++, x--, y++, y-- and diagonal at speed 0.1f (0.1 * ftime). The player can also jump. And there is gravity pulling the player down. Relative movement is saved in: relx, rely and relz. One solid cube on the map is exactly 1.0f width, height and depth. The problem I have is to adjust the player position when colliding with solids, I don't want it to bounce or anything like that, just stop. But if moving diagonal left/up and hitting solid up, the player should continue moving left, sliding along the wall. Before moving the player I save the old player position: oxpos = xpos; oypos = ypos; ozpos = zpos; vec3 direction; direction = vec3(relx, rely, relz); xpos += direction.x*ftime; ypos += direction.y*ftime; zpos += direction.z*ftime; gx = floor(xpos+0.25); gy = floor(ypos+0.25); gz = floor(zpos+0.25); if (bMap[gx][gy][gz] == true) { vec3 normal = vec3(0.0, 0.0, 1.0); // <- Problem. vec3 invNormal = vec3(-normal.x, -normal.y, -normal.z) * length(direction * normal); vec3 wallDir = direction - invNormal; xpos = oxpos + wallDir.x; ypos = oypos + wallDir.y; zpos = ozpos + wallDir.z; } The problem with my version is that I do not know how to chose the correct normal for the cube side. I only have the bool array to look at, nothing else. One theory I have is to use old values of gx, gy and gz, but I do not know have to use them to calculate the correct cube side normal.

    Read the article

  • Operations on multiple overlapping layers not working

    - by Arun
    Hi I am developing a game in android just like Farmville by Zinga. In that game we have to place elements in the diamond shaped field so the don't overlap each other. Now I did coding for placing the field inside the farm field but I cannot stop the problem of overlapping of the farm field. I Am attaching the code that I have down for all this someone please help me.... try{ if(bm1.getPixel((int)initX,(int)initY)!=0){ if(bm1.getPixel((int)initX,(int)initY+20)!=0){ if(bm1.getPixel((int)initX-20,(int)initY)!=0){ if(bm1.getPixel((int)initX+20,(int)initY)!=0){ if(bm1.getPixel((int)initX,(int)initY-20)!=0){ c.drawBitmap(bm,initX-30,initY-20, paint); } } } } } }catch(Exception e) { Toast.makeText(getContext(), e.toString(), Toast.LENGTH_SHORT); }

    Read the article

  • Unity, changing gravity game & stopping character when he hit a wall.

    - by Sylario
    i am currently working on a 2d puzzle game in the unity engine. One of the aspect of this game is the possibility to rotate the level of 90°. It also rotate the gravity. The main character is not directly controlled by the player, but instead fall when the level is rotated. When the main character hit a wall, he should stop to move. If i do not stop it, it kind of blink ans shake against the wall. To stop it i detect collision and depending on the current rotation state, the player will stop at "vertical" or "horizontal" tags when a OnCollisonEnter occurs. I must do that because when the player fall on his relative ground, He must not stop like if he had touch a wall. My problem is the 'side' of platform, or the 'top' of wall, they use the same tag and thus do not give the correct tag to my character. I tried to put a very small invisible box on top/side of elements but the collision occurs nevertheless. It seems when the player falls and hit something he go through a bit before being replaced at correct position by unity. Is there a way : 1 ) to doesn't stop my character but to make it appear immobile on screen 2 ) To detect a "i cannot move anymore" collision other than by using collision?

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >