# How can I increase the hit range of a node?

How can I set the radius or the hit range of a node initialized with a texture? Of course I can do that with increasing the size of it, but actually I want to do this without resizing the picture itself. This node is moving around the screen with a small speed. This is my code:

func addMonster() {

let monster = SKSpriteNode(imageNamed: "MosquitoDrawed")

monster.name = predatorNodeName

monster.zPosition = 1

monster.position = CGPoint(x: random(-10.0,max: -30.0), y: random(10.0, max:130.0))

let actualDuration = 7.0

let actionMoveTo = SKAction.moveTo(CGPoint(x: random(500, max:800),y: random(1, max:800) ), duration: NSTimeInterval(actualDuration))

monster.runAction(actionMoveTo,withKey: "move")

}


Have you tried to initialize your SKPhysicsBody with a rectangle of the size you want?

var node = SKSpriteNode(imageNamed: "node.png")
node.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: 50, height: 50))


That way you can increase the size of the bounding box of your node without using a larger image.

More details in the docs.

Hope it helps!

• Great ! I did change the PhysicsBody , but the hit range is still not affected. Also there's another bug that appeared after after this, the node goes up and down fast while moving. – xdevx32 Mar 9 '16 at 16:27
• Without seeing any code, it's a bit hard to help you. You should add it to your question ;) – Heyfara Mar 9 '16 at 16:31
• Yes, you're right. I just updated my post. – xdevx32 Mar 9 '16 at 16:33
• You are talking about "hit range", but I can't see collision detection in your code. How did you test that the "hit range" was not affected? I suggest you to read the [docs about simulating physics](You should read [the docs] (developer.apple.com/library/ios/documentation/GraphicsAnimation/…) about simulating physics. ). It should give you pointers on what's missing. – Heyfara Mar 9 '16 at 16:41