# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### Dark Physics & Dark A.I. & Dark Dynamix / Camera Orientation -> Object linear Velocity

Message
Posted: 21st Dec 2010 17:29 Edited at: 22nd Dec 2010 10:26
Hi coders
I'm trying to understand the Maths of 3D World & i need some Help..

I have Camera Targeting a Ball with Physics,
i want to give phy linear velosity dipending from my Camera Orientation, how can i do that?
(Push forword away from the cam)

thanks

#### Attachments

Posted: 22nd Dec 2010 10:33
Hello Coders

I'm traing to understand the 3D World and i need some help
I have a Camera Following/Targeting a Ball and i want pressing the space to give phy linear velocity away from the camera orientation.

my code..

` Main Loop
do
if mouseclick()=1 then phy set rigid body linear velocity 10,50,0,50

`Rotate camera around Ball
cama#=wrapvalue(MouseX())
position camera object position X(10)+cos(cama#)*65,object position Y(10)+40,object position Z(10)+sin(cama#)*65
point camera object position X(10), object position Y(10)+25, object position Z(10)

phy update
sync
loop
Posted: 22nd Dec 2010 10:35
Hello Coders

I'm traing to understand the 3D World and i need some help
I have a Camera Following/Targeting a Ball and i want pressing the space to give phy linear velocity away from the camera orientation.

my code..

` Main Loop
do
if mouseclick()=1 then phy set rigid body linear velocity 10,50,0,50

`Rotate camera around Ball
cama#=wrapvalue(MouseX())
position camera object position X(10)+cos(cama#)*65,object position Y(10)+40,object position Z(10)+sin(cama#)*65
point camera object position X(10), object position Y(10)+25, object position Z(10)

phy update
sync
loop

#### Attachments

Posted: 22nd Dec 2010 14:50
This code moves a sphere around dynamically. It uses the arrow keys for movement and if you press space it will jump. Hopefully, this will help you with moving the ball away from you.

Posted: 22nd Dec 2010 17:49 Edited at: 22nd Dec 2010 18:42
LBFN - Exactly what I need! Like the code, was just in the middle of changing my game controls to work better, as my old ones worked ok, but the ball stopped rotating when I moved around. Only spinning when letting go of the keys. you have saved me a fair bit of time there! Many thanks! Plopped it into my game instead of my old routine and worked like a charm! Just need to give it a bit more speed now
I was thinking of rotating the whole level to make the ball move, but this is a little less intensive and helps keep speed up!

Edit - Having more trouble than I anticipated. I can speed up the up and down key movement easily enough. The left and right however, doesn't seem to alter whatever I change the step value to or increasing the velx# and velz# =<20 check value up for down.. I'm missing something silly lol.

http://s6.bitefight.org/c.php?uid=103081
Posted: 23rd Dec 2010 12:31 Edited at: 24th Dec 2010 16:13

Glad it was of some help to you.

I don't think you are missing something silly, as I tried to quickly alter it to work like you are wanting and got the same results. I will be busy at work the rest of the day, unfortunately. I plan to take another look at it tomorrow to see if I can solve it. If you figure it out in the meantime, please let me know.

EDIT: Worked on it some today. It is going to take some experimentation to figure this out.

Posted: 24th Dec 2010 21:34
Got a solution a fellow coder suggested. Obvious really, and I should have tried it earlier, rather than banging my head getting the existing code to work.

That uses the same structure as the first code and works just as well. Not sure why the method was changed for left and right originally, but for my needs this works perfectly.

http://s6.bitefight.org/c.php?uid=103081
Posted: 25th Dec 2010 02:17
As I recall, I could not get something similar to what you posted to work, so I changed it. Anyway, thanks for sharing.

Posted: 25th Dec 2010 22:43
No probs, works ok for me anyway. Probably left the step value a little high, but I wanted to test speedy lol.

http://s6.bitefight.org/c.php?uid=103081
Posted: 7th Mar 2011 20:39
umm the code LBFN wrote worked fine for me
I could not move right or left any more

that's the end of thought for this

If a thought is Just a thought ~ so whats the main thought ?
Posted: 7th Mar 2011 21:03
It works fine for me. I changed DVader's rigid body ID number back to 1 instead of 100.

Posted: 7th Mar 2011 21:08
ahh ok thanks LBFN

If a thought is Just a thought ~ so whats the main thought ?
Posted: 7th Mar 2011 22:45 Edited at: 7th Mar 2011 22:46
for any one else showing up this is the complected file

If a thought is Just a thought ~ so whats the main thought ?