Skip to main content
gamedev.net
🔒 Locked

simple triga help

Started by NerdAndy 0 replies 850+ views
Original Post
NerdAndy
NerdAndy
hi everyone am making a simple 3d game with 2d math, and i need a lil help moving my cam and my light direction (head light). so using some hight school math i got my object to rotate and go in the direction i want it to. now i want my cam to stay behing my objct and the light to say in front even when i rotate. example: http://img448.imageshack.us/my.php?image=help8ec.jpg am using C# and DirectX thanks again
I just want to be better than "you" ;-(
BeanDog
BeanDog
You could store the direction the object is facing (either as a theta (angle) value or as a vector saying which direction he's pointing). Then, to determine a point in front of him, you could just take his direction, multiply it times a positive number, and get a point in front of him to put your light. Or multiply it by a negative number, and get a point behind him to put your camera. Of course, the camera needs more than a position, but if you have the camera's position and your character's position, you should have enough to at least get your camera to work, and you can worry about smoothing out its motion later.

For instance, if you stored a theta value:
lightx = player.x + cos(player.theta)*lightdist;lighty = player.y + sin(player.theta)*lightdist;


Does that answer your question?



~BenDilts( void );

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.