title: iOS: Setting velocity does not working sprite kit
body: <p>I'm currently making an app using sprite kit. I'm trying to change the velocity of an object when the user swipes up. However, the velocity doesn't change even though the function is called.
  Here's my code:</p>
  
  <pre><code>- (void)swipedUp {
      NSLog(@"swiped up!");
      _player.physicsBody.velocity = CGVectorMake(_player.physicsBody.velocity.dx, 200.0f);
  }
  </code></pre>
  
  <p>I am able to change the velocity in another function called in the update function:</p>
  
  <pre><code>-(void)update:(CFTimeInterval)currentTime {
      /* Called before each frame is rendered */
  
      _player = [self updatePlayer];
  
      [self moveBackgound];
  }
  
  - (SKNode *)updatePlayer {
  
      /* Create the node */
  
      SKNode *playerNode = [SKNode node];
      SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"Car_normal.png"];
  
      // dx &gt; 0 =&gt; right ; dy &gt; 0 =&gt; up
      _player.physicsBody.velocity = CGVectorMake(0.0f, 10.0f);
  
  
      if (_player.physicsBody.velocity.dy &lt; 0.0f) {
          sprite = [SKSpriteNode spriteNodeWithImageNamed:@"Car_brake.png"];
      }
  
      [playerNode addChild:sprite];
  
  
      return playerNode;
  }
  </code></pre>
  
  <p>In the current version, I removed the
  <code>_player.physicsBody.velocity = CGVectorMake(0.0f, 10.0f);</code> ligne in the updatePlayer function, but it still doesn't change the velocity.</p>
  
  <p>I also tried calling the updatePlayer function from the swipedUp function using a boolean to make sure I should change the velocity. Again, the ligne is read but the velocity change isn't applied.
  I previously had a similar problem in another app to change the text of a UILabel. I used <code>[_player performSelector:&lt;#(SEL)#&gt; onThread:&lt;#(NSThread *)#&gt; withObject:&lt;#(id)#&gt; waitUntilDone:&lt;#(BOOL)#&gt;]</code>. However, I need to pass a CGVector which is not of type 'id' so I cannot use that ligne of code.</p>