# 3Dengine, need help with controls

**URL:** https://forum.kirupa.com/t/3dengine-need-help-with-controls/303606
**Category:** programming
**Created:** [January 23, 2010, 3:36am UTC](https://forum.kirupa.com/t/3dengine-need-help-with-controls/303606 "2010-01-23T03:36:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sherpak](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@sherpak](https://forum.kirupa.com/u/sherpak)
#### Post date: [January 23, 2010, 3:36am UTC](https://forum.kirupa.com/t/3dengine-need-help-with-controls/303606/1 "2010-01-23T03:36:04Z")

</div>

heya all,

edit: [http://ezakirth.free.fr/test/](http://ezakirth.free.fr/test/) works now 😃

I started this 3D engine from the ground up mostly just to understand how they’re done, but now I want to see how far I can go.  
The goal is a top view 3D zelda like game that i would eventually port to iphone (hence the controls)

I’m there atm: [http://ezakirth.free.fr/test/](http://ezakirth.free.fr/test/) with some really messed up toon rotation 😛  
It’s not really optimized and no physics are implemented yet, only semi cute thing here are the non-character textures with fake lightning ^^

Anyways, I usually come up with a solution to problems on my own, but i’m getting pretty angry at myself right now…

I just can’t find a way to implement the character orientation based on a joystick direction.

I get the joystick angle with

```auto
ang = Math.atan2(pad.ctrl._y, pad.ctrl._x);

```

I then loop through all the vertices in my toon’s array and attempt to rotate them accordingly

I tried implementing the two rotation around Y axis formulas that i know and neither are working for me.  
[http://ezakirth.free.fr/test/test.html](http://ezakirth.free.fr/test/test.html) (click on formula to change type)

the first one i feel i could do something with, but I can’t find a way to implement it. My toon is a cube atm, therefore all the points are at the same distance from the center, which messes it all up ☹

```auto
for...
 {
        toon[j].x = cos(angle)*dist + tcenterx;
        toon[j].y = sin(angle)*dist + tcentery;    
 }

```

when i try to “off” the cube’s center, i get this:[http://ezakirth.free.fr/test/test2.html](http://ezakirth.free.fr/test/test2.html)  
My model is now flat ☹

I don’t think i can use the second formula here as it works by increments, not a set angle, and it would feel like a scary amount of work to make it…mmm…work.

Anyone have any idea on what i should do ?

Best regards,
