Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/20/24 06:09
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, Edgar_Herrera), 695 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Moving on an to center y axis automaticly [Re: ] #453589
08/02/15 16:35
08/02/15 16:35

M
Malice
Unregistered
Malice
Unregistered
M



Here is the logic chain here
1) locate a vector that points from the player to 0-Y'
2) move along the vector till the player is as close as possible to 0-Y
3) snap the player to 0-Y

secondary logic
1) do not move along the vector unless landing
2) stop the move if landed

logic of the code
1) define vectors
VECTOR vec_temp
Vector vec_temp2

2) set vector to my location
vec_set(vec_temp,my.x)

3) get a abs vector to 0-Y
vec_diff(vec_temp2,nullvector,vec_temp);

4) change the vector length without changing it's direction to get a speed along the direction vec
vec_normilize(vec_temp2,5*time_step);

5) set a lock
if(vec_dist(my.y,vec_temp2.y)>5)

6)move along the direction at speed 5*time_step, along the abs vec
c_move(my,nullvector,vector(0,vec_temp2.y,0),GLIDE);

7) snap to the 0-Y ( step-5 if is now false)
vec_set(vector(0,my.y,0),nullvector);


Last edited by Malice; 08/02/15 16:37.
Re: Moving on an to center y axis automaticly [Re: ] #453593
08/02/15 18:31
08/02/15 18:31
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Malice, your code is good, but for 3 dimensions.

Just for one (y) , y * 0.9 is easier and simple, and doesnt need a lock.
Simply scaling down the y pos until it becomes as close as 0, every frame.


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Moving on an to center y axis automaticly [Re: EpsiloN] #453595
08/02/15 18:49
08/02/15 18:49

M
Malice
Unregistered
Malice
Unregistered
M



Sure I get it.
muling the my.y by that factor will reduce it towards 0 every frame regardless of the sign of my.y pos.
it is not regulated by time_step.

The basic logic is a mul by .9 reduces the my value by 10% and to increase the shift rate you decrease the decimal value.
So then a mul by .75 will decrease the my.y pos by 25% per loop.

I understand, but does the OP understand. We both present a logic design to achieve the same effect. But if the OP doesn't see the logic then they can never use that logic to create variation for similar effects.

Re: Moving on an to center y axis automaticly [Re: ] #453598
08/02/15 19:09
08/02/15 19:09
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
You are right.

I started with 3dgs so i never learned to design programs. I recently picked up that skill from a Java tut and now I know what I've been missing for the past 15 years laugh


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Page 2 of 2 1 2

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