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.

Code Snippets / Strafing your camera, left and right

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 6th Sep 2006 03:48 Edited at: 8th Sep 2006 22:32
'Cam' is the camera number.
'LR#' stands for 'left or right'. To move left, specify a negative number. To move right, specify a positive number. The lower the negative number, the more you move left. The higher the positive number, the more you go right.

Hope you understand!


Updated to use arrays! Thanks!




-Xeno


Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 6th Sep 2006 18:18
Looks usefull... but maybe you should make an array for sin and cos and use the array-values, i think it would increase the speed of it.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 6th Sep 2006 20:52 Edited at: 6th Sep 2006 20:53
Why would that happen? You would have to fill the array, then use the array in place of the sin/cos values, where this way you can just do it straight.

[edit]
Cool function btw

Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 7th Sep 2006 18:28
@ Zotoaster: I think, it's faster, using this array... look at this example:



On my computer, the way using commands comes to ~160 fps, and the array-method to ~500 fps. I think, the commands need more time, because they are also made for Floats, but if you don't need floats, this way is even faster.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Sep 2006 22:02
An array should be faster cause it's just a block of allocated memory. The index to the array is a pointer to the area in memory where the value is stored, so pointing directly to that index and retrieving a value is faster than calculating it. If memory isn't a problem, use the array.

Now if you have to search through the whole array one index at a time to find a value, you will slow down.

Enjoy your day.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 8th Sep 2006 22:30
Right, thanks for that, thats really clever

Updated code... in a sec


Login to post a reply

Server time is: 2024-11-23 03:22:43
Your offset time is: 2024-11-23 03:22:43