# Ball Movement In 3D / Vectors Relative to Current Direction

**URL:** <https://forums.kodeco.com/t/ball-movement-in-3d-vectors-relative-to-current-direction/35629>\
**Category:** 3D iOS Games by Tutorials\
**Created:** [October 17, 2017, 9:34am UTC](https://forums.kodeco.com/t/ball-movement-in-3d-vectors-relative-to-current-direction/35629 "2017-10-17T09:34:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thehyperpixel](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@thehyperpixel](https://forums.kodeco.com/u/thehyperpixel)\
**Post date:** [October 17, 2017, 9:34am UTC](https://forums.kodeco.com/t/ball-movement-in-3d-vectors-relative-to-current-direction/35629/1 "2017-10-17T09:34:21Z")

</div>

Hi,  
I followed the Marble Madness tutorial which is great. I then wanted to push this demo further by getting the camera to follow the ball behind it (which I did successfully).  
I then turned off gryo and instead decided to add some virtual D-Pads to the screen which provide a -1/+1 value for both the X/Y location where you touch (based on code from Apple’s demos).  
The left pad should control the ball direction (forward / backward and turn it left or right) whilst the right D-Pad controls the camera.

I now want to map the left D-Pad values to the vector that the ball travels in.

The trouble is, when I press it, pressing right on the D-Pad always makes the ball travel globally in the same direction - not relative to its current location or vector.

I’ve tried for hours to change this, and have played around with “convertVelocity” methods but I can’t get it to work.

I’ve attached an image showing my screen.

 ![IMG_3047](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/6/c/6c9b2336657e62643d5e4cadb5fa72e522908fcc.jpg)

If anyone else has had this trouble, I would really appreciate your thoughts.  
James

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [April 2, 2018, 1:34am UTC](https://forums.kodeco.com/t/ball-movement-in-3d-vectors-relative-to-current-direction/35629/2 "2018-04-02T01:34:32Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
