Hi everyone. I just finished the initial tutorials. Now I am trying to slowly develop my skills by making little projects.
I have made a project with a guy that walks around in a room. I have set it so the camera follows over the shoulder of the walking guy.
Now I want to make it so that if the Alt key is pressed, the arrow buttons will move the camera around the guy but still look toward the guy, as in Secondlife.
Can anybody steer me in the right direction of how to code that? or if you have a snipped of code with comments so I can figure out how it works, that would be cool too.
Thanks. Here is my crappy little program:
//make a guy that walks around//
#include <acknex.h>
#define STATE skill1
#define ANIMATION skill2
var walk_percentage;
function main()
{
level_load("walkin_room.wmb");
}
function camera_follow(ENTITY* ent)
{
while(1)
{
vec_set(camera.x,vector(-150,10,50)); // camera position relative to the player
vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
vec_add(camera.x,ent.x); // add player position
vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down
wait(1);
}
}
action walkA()
{
while(1)
{
my.pan += (key_cul - key_cur)*8*time_step;//make it so he can turn//
var distance = (key_cuu - key_cud)*8*time_step;
c_move(me, vector(distance,0, 0), NULL, GLIDE);//make him move forward and back//
my.ANIMATION += 2*distance;
ent_animate(me, "walkA", my.ANIMATION, ANM_CYCLE);
if (key_space)
{
ent_animate(me, "jumpA", my.ANIMATION, ANM_CYCLE);
}
camera_follow(me);
wait(1);
}
}
p.s.I am really enjoying gamestudio so far. I haven't done any programming since I packed away my old Radio Shack color computer2 about twenty-five years ago, but programming seems easier now than it did back then.