Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,586 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
using c_trace, accelerate and c_move for gravity #367126
04/10/11 04:15
04/10/11 04:15
Joined: Mar 2011
Posts: 11
R
RetroGamer Offline OP
Newbie
RetroGamer  Offline OP
Newbie
R

Joined: Mar 2011
Posts: 11
this might be a stupid question. but im trying to call gravity from its own function by using a c_trace, then a single c_move in the player action.
but im having a issue figuring this out.

1. i want to use a c_trace to find the distance to the floor.
like
Code:
floor_dist = (c_trace(my.x,nullvector,my.z -1000),USE_BOX);



2. i would like to change the absoute force in script for winds, low gravity and perhaps extreme gravity.

3. from what i read accelerate can be used to apply gravity (outside forces) to my player, but it doesnt have collision detection. can it be used with a c_trace and c_move?

can someone write a basic code here to outline the way to do this. Just need a basic idea.
Perhaps its my use of VECTOR and/or var (both can be used for x,y and z(tho only curious about .z movement)).
I never used c_move or c_trace before.
i dont get errors just not the results i thought
I know how they are defined, i read everything i could find about em.
I just seem to make things harder then it is.

Thanks in advance for anyone willing to give any assist.


ever hear the expression once you learn it's hard to forget...
I think learning programming languages as,

I just mastered old school roller skating...
Now they have roller blades, Same wheels, different setup
Re: using c_trace, accelerate and c_move for gravity [Re: RetroGamer] #367127
04/10/11 07:14
04/10/11 07:14
Joined: Mar 2009
Posts: 88
Walori Offline
Junior Member
Walori  Offline
Junior Member

Joined: Mar 2009
Posts: 88
To get trace working along the c_move in two different functions you need towthings, a vector/variable that stores the distance got by c_trace (I'd go with vector , see below) and a list of entities you want function to affect.

I'd go with something like this: First "register" entities you've created to a array, lets say 10 of size. (ENTITY* ent_registered[10]) Along this array you have a VECTOR array of same size (both are global of course in this case). Here the vector array's size would be 10 (VECTOR vec[10]) then add movements to vectors. After they've been added get the movements to c_move by number you've saved the vectors. Easiest way for this is to register ent by certain number and use that same number for its vectors

The code itself is easy once you figure it out, good luck laugh

Re: using c_trace, accelerate and c_move for gravity [Re: RetroGamer] #367152
04/10/11 14:33
04/10/11 14:33
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: RetroGamer
1. i want to use a c_trace to find the distance to the floor.
like
Code:
floor_dist = (c_trace(my.x,nullvector,my.z -1000),USE_BOX);


That code you posted is - sorry - nonsense. The first argument of c_trace is the origin of the ray to sent. You wrote my.x, that's valid. As the second argument you gave the nullvector. That does not make any sense. You don't want to trace from every entity to the levels origin, but to a point below the entitiy. Replace nullvector with something like "vector(my.x,my.y,my.z - 1000)". The next argument is the the tracemode, but you wrote my.z - 1000. That's just a mistake because you were mixing functions, eh? I really wonder this even compiles, because you called the function with one argument to much. The use of USE_BOX however is ok again. So the corrected line should look basically like this:
Code:
dist = c_trace(my.x,vector(my.x,my.y,my.z -1000),USE_BOX);



Keep in mind the distance to the floor is already available in the entities floor_dist member. So tracing again might be superfluous if you floor_dist suffices your needs.

Originally Posted By: RetroGamer
2. i would like to change the absoute force in script for winds, low gravity and perhaps extreme gravity.

You just need to add those forces togehter with vec_add. That's not a problem becuase all these forces are absolute forces.

Originally Posted By: RetroGamer
3. from what i read accelerate can be used to apply gravity (outside forces) to my player, but it doesnt have collision detection. can it be used with a c_trace and c_move?

accelereate does not have collision detection as it does not move anything. So, deteting collisions that are impossible to happen is a hard task - even for JCL. ;-)

Accelerate requires a current speed, a force and a friction parameter and calculates the resulting speed out of these parameters. You can and in most cases should use the resulting speed with c_move.


Always learn from history, to be sure you make the same mistakes again...
Re: using c_trace, accelerate and c_move for gravity [Re: RetroGamer] #367177
04/10/11 16:50
04/10/11 16:50
Joined: Mar 2011
Posts: 11
R
RetroGamer Offline OP
Newbie
RetroGamer  Offline OP
Newbie
R

Joined: Mar 2011
Posts: 11
yea that code piece was just an example (i did realize it was completely wrong(was tired at that time).

switching from a5 .wdl to a7-a8 lite-c is tedious,
i seem to run into simple but confusing changes time to time,lol.
Thank You, the explanation helps alot


ever hear the expression once you learn it's hard to forget...
I think learning programming languages as,

I just mastered old school roller skating...
Now they have roller blades, Same wheels, different setup

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

Gamestudio download | 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