• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Camera position and object

C

Constant

Guest
Hello,

I am struggeling with positioning a camera in front of an object.
In a room I create one object (my_obj) and a camera (obj_cam).

my_obj should be in the center of the room.
obj_cam should be in one line with my_obj.
room.png
To position my_obj in the center of the room I use in my_obj_Create:
my_obj.x = room_width/2;
my_obj.y = room_height/2;

To position obj_cam in front of my_obj I have to use in obj_cam_Draw:
d3d_set_projection(xfrom, yfrom, zfrom, xto, yto, zto, xup, yup, zup)

Somehow I don't succeed in doing this.
- I am not able to find the correct values for d3d_set_projection
- I have problem with the distance between obj_cam en my_obj
- I cannot put the camera in front of my_obj and in one line towards my_obj
- How are my_obj.x en my_obj.y related to obj_cam?

Can somebody help me.
It seems so simple but for me it's not.

Thanks in advance.

Regards,
Tnatsnoc
 

Gamerev147

Member
I assume you're making a 3D game since you're using d3d_set_projection()?
d3d_set_projection is for 3D games.

Also, when you're setting the x and y of an object IN the object (for itself) you don't need to put the object name.
So for my_obj in the created event, you don't need my_obj.x = x;
You can just put: x = room_width/2; Same thing goes for Y.
 
Top