D
Dibidoolandas
Guest
I'm using objects as background elements so I can sort of build my levels piece by piece. However I want some of these background (or foreground) objects to parallax slightly. I've got the effect working in a way that I like using the following code (this is a snippet for a foreground object):
Create:
Step:
This works great, and you can see variants of it in this video, in the background tree, the shinto gates, and the foreground rocks.
However, I've noticed if I place something near the left side of my room (which is quite long), it renders relatively close to where I placed it. But if I place one of these objects halfway into the room, it is very far from where I placed it, as far as the x position is. I assume this is because it's checking the view against the relative position of the room. Not to oversimplify things, but is there a way to do the same thing, but just check against where the object is in relation to the current viewport?
I know it's a bit hard to explain, but if the camera moves over the center of where I placed the object in the room, I'd like the object to appear in the center, but if the camera is to the left or right it should adjust its position accordingly.
Create:
Code:
off_x = x;
off_y = y;
Code:
x = off_x+(-view_xview[view_current])/5;
y = off_y+(-view_yview[view_current])/5;
However, I've noticed if I place something near the left side of my room (which is quite long), it renders relatively close to where I placed it. But if I place one of these objects halfway into the room, it is very far from where I placed it, as far as the x position is. I assume this is because it's checking the view against the relative position of the room. Not to oversimplify things, but is there a way to do the same thing, but just check against where the object is in relation to the current viewport?
I know it's a bit hard to explain, but if the camera moves over the center of where I placed the object in the room, I'd like the object to appear in the center, but if the camera is to the left or right it should adjust its position accordingly.