Page 1 of 1

Unique View moving style

PostPosted: Mon Jan 07, 2013 6:28 pm
by arcreamer
Hey guys so heres what Im trying to do. I want to make it so that whenever my actor hits my moveview_right (or any other direction) instead of the view moving with the character, I want to make it so that the view moves, say, 20 feet to the right automatically and then stops, as to show what the next part of the level is instead of consistently moving with the player. The script I have now with the collision of the moveview_right and player is

Code: Select all
view.x+=10;

Re: Unique View moving style

PostPosted: Tue Jan 08, 2013 12:20 am
by Hblade
I know an interesting one. Try this (Of course, replace event.x with your player actor)

View Draw Actor:
Code: Select all
angle=direction(x, y, event.x, event.y);
directional_velocity=distance(x, y, event.x, event.y)/2;

Re: Unique View moving style

PostPosted: Wed Jan 09, 2013 8:52 pm
by arcreamer
I like how it adjusting the last digit can change the speed of the view following the actor, but for some reason when I hit play, the view drops to the bottom right and i can barely even see my charactor's feet on top left corner of the screen

Re: Unique View moving style

PostPosted: Wed Jan 09, 2013 8:56 pm
by skydereign
That's because the code is using the player's xy. The view actor's xy is based off of the top left of the view. You'd have to use (x+width/2, y+height/2, event.x, event.y), for the direction and distance functions, as that will put the player at the center.

Re: Unique View moving style

PostPosted: Wed Jan 09, 2013 9:02 pm
by lcl
arcreamer wrote:I like how it adjusting the last digit can change the speed of the view following the actor, but for some reason when I hit play, the view drops to the bottom right and i can barely even see my charactor's feet on top left corner of the screen

That's because the code has an error. It should be:

Code: Select all
angle=direction(x, y, event.x - width * 0.5, event.y - height * 0.5);
directional_velocity=distance(x, y, event.x - width * 0.5, event.y - height * 0.5)/2;

Because view coordinates are its top left corner coordinates, not the center. :)
If we decrease half of the views size from the coordinates to move to, it goes to the right place.

I see that skydereign was faster, but I think my explanation could be useful too. =)

Re: Unique View moving style

PostPosted: Wed Jan 09, 2013 9:17 pm
by arcreamer
I understand, thanks guys

Re: Unique View moving style

PostPosted: Wed Jan 09, 2013 11:49 pm
by RippeR7420
Thank you! And I use the same code Hblade gave you in your topic "Unique View moving style". But the difference is, I gave the view a limit so it couldn't move any further up or down, just left or right.

and to do that, you simply type this code;

view-> draw actor-> script editor->
Code: Select all
x=min(max(x, -320), 5680); // This limits the the views "x" coordinates so they cant go any further left than -320, or no further right than 5680.

y=min(max(y, -240), -240); // This limits the views "y" coordinates so they cant go any further up than -240, or any lower than -240. So it locks it in place.


Just like Sky said, Always remember that the view center point isn't in the middle of the view, but the top - left corner.

I hope that helps!

Re: Unique View moving style

PostPosted: Wed Jan 09, 2013 11:51 pm
by RippeR7420
I tried to message that to you arcreamer, but you have private messages disabled. :)