Gamestudio Links
Zorro Links
Newest Posts
How to buy tomorrow at open?
by frutza. 06/01/23 19:58
Adding Position to Current Trade
by AndrewAMD. 05/30/23 10:34
Unable to change multiplier of contract
by vicknick. 05/30/23 06:56
Wrong Definition of Sharpe Ratio in Zorro?
by vicknick. 05/29/23 06:32
Backtest strategy on bitcoin/crypto
by JamesHH. 05/26/23 04:36
Return type of floor()
by AndrewAMD. 05/25/23 14:17
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (AndrewAMD), 1,065 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
BInnacle, androsa, XquicksnowX, danishinvest, Trail
18942 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
camera.x == player.x #327693
06/07/10 22:20
06/07/10 22:20
Joined: May 2009
Posts: 5,366
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,366
Caucasus
How do I set separately camera.x and camera.y to player.x and player.y from camera.z = player.z? That's be cause I set all of them with vec_lerp, to make movement smoother, but cameras X and Y aren't equal to players X and Y be cause of that. Thats why I want to separate them. I want to set cameras X & Y to players X & Y by vec_set, and then to lerp cameras Z to players Z. Is that possible? Explain how to do that please. Thank you.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: camera.x == player.x [Re: 3run] #327694
06/07/10 22:31
06/07/10 22:31
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
camera.x = player.x;
camera.y = player.y;
camera.z += clamp((player.z-camera.z)*0.1,-5,5)*time_step;

I don't really understand what you are trying to do, but try my code example above.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: camera.x == player.x [Re: Superku] #327702
06/07/10 23:43
06/07/10 23:43
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Code:
...
   var lerped_z = (1-LerpAmount)*player.z + LerpAmount*other_z;
   vec_set(camera.x, vector(player.x, player.y, lerped_z));
...


In Lerped_z formula, you many need to swap player.z and other.z around to get what you want...

Or, another way is this
Code:
...
   VECTOR tempV;
   vec_lerp(tempV, player.x, vector(player.x, player.y, other_z), LerpAmount);
   vec_set(camera.x, tempV);
...



NOTE, neither of these snippets have been tested...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: camera.x == player.x [Re: EvilSOB] #327706
06/08/10 00:03
06/08/10 00:03
Joined: May 2009
Posts: 5,366
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,366
Caucasus
I've tried to do like this:
Code:
vec_lerp(vector(camera.x,camera.y,0),vector(camera.x,camera.y,0),vector(player.x,player.y,0),0.2);
vec_lerp(vector(0,0,camera.z),vector(0,0,camera.z),vector(0,0,player.z),0.2);


But of course it fails grin Superku, to make players camera to move smoother, I just made it to move smoother after the player, but that way, when you stand and look around you can notice that the camera center is not in the players center, will looks like you are turning around the player model, that why I want cameras X and Y to be always at the players center (X and Y), but Z must move smoother after the player. Play my beta project, you'll notice what I'm talking about.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: camera.x == player.x [Re: 3run] #327707
06/08/10 00:12
06/08/10 00:12
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Have you tried my code? It does that exactly.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: camera.x == player.x [Re: 3run] #327708
06/08/10 00:20
06/08/10 00:20
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
3run,

check the manual and you'll see that using the 'vector function' only creates a temporary vector.
vec_lerp stores its result in the first parameter.
So you are storing your results in a temporary vector, NOT in the actual camera properties.
So your results with these commaands will be inconsistant.

What Beta project are you talking about? So I can see it in action...
(just post a link to your project thread please)


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: camera.x == player.x [Re: EvilSOB] #327711
06/08/10 01:09
06/08/10 01:09
Joined: May 2009
Posts: 5,366
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,366
Caucasus
Here is my project:
War Cloud
Will it work, if I'll do the first line with vec_set and the second one with vec_lerp.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: camera.x == player.x [Re: 3run] #327718
06/08/10 04:13
06/08/10 04:13
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
OK,

I think this is what you are after. I assume this code gets run once per frame.
Ditch both old camera-control lines, and replace with this (untested) code.
Code:
...
   VECTOR tempV;   //note:: this line can be outside(before) the loop
...
   vec_lerp(tempV, vec_diff(tempV, camera.x, player.x), 0.2);
   vec_set(camera.x, vec_add(tempV, player.x));
...



PS :: You could also use three spare player.skill's instead of tempV if you want...

Last edited by EvilSOB; 06/08/10 04:17. Reason: PS added

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: camera.x == player.x [Re: EvilSOB] #327720
06/08/10 04:58
06/08/10 04:58
Joined: May 2009
Posts: 5,366
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,366
Caucasus
OK thank you man laugh I've got it now. What about my project any way? laugh Did you like it? Please reply in my project topic laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1