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,388 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
Page 1 of 2 1 2
Spherical gravity #367729
04/17/11 08:49
04/17/11 08:49
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Hey people,
I know that this was asked a lot of times.
I use the code of JulzMighty. Thank you for that! laugh

But the problem is, that the camera goes crazy.
If i´m on a wall and just change the tilt angle, then it´s different than if i´m on ground.

I hope you understand what i mean.
If not, then i´ll upload a testlevel.

Can someone make an example and provide it?


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Spherical gravity [Re: alibaba] #367730
04/17/11 08:54
04/17/11 08:54
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Could you please upload it somewhere?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Spherical gravity [Re: 3run] #367732
04/17/11 09:13
04/17/11 09:13
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Okay, i uploaded it.
In this Version everything works fine, but i can´t look around with the camera.
If you comment out the line "camera.tilt=my.tilt" and remove the double slash at "camera.tilt+=2*mouse_force.y" then you can look around, but only at the ground. If you walk up the Walls, the it´ll mess up.

http://ifile.it/rqnx3po


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Spherical gravity [Re: alibaba] #367733
04/17/11 09:47
04/17/11 09:47
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Here you go dude [FIXED AND TESTED]:
Download link
As I thought, problem wasn't with the camera laugh
Main problem was adapting player's pan to normals))
BTW look at the script, I've made few improvements blush


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Spherical gravity [Re: 3run] #367735
04/17/11 10:01
04/17/11 10:01
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Thank you 3run, but my problem isn´t the pan. My problem is, that i can´t tilt the camera with the mouse. So the main problem is that i can´t look around correctly with the camera.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Spherical gravity [Re: alibaba] #367742
04/17/11 13:25
04/17/11 13:25
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Quote:
I use the code of JulzMighty. Thank you for that! laugh
You're welcome grin I'm glad to see it in use!

Try this new action:
Code:
action le()
{
	player=me;
	var relTilt = 0;
	while(1)
	{
		gravitz();
		c_rotate(my,vector(-2*mouse_force.x,0,0),GLIDE|IGNORE_PASSABLE|USE_AXISR);
		c_move(my,vector((key_w-key_s)*20*time_step,(key_a-key_d)*20*time_step,walk_speed.z),nullvector,GLIDE | IGNORE_PASSABLE|IGNORE_FLAG2);
		vec_set(camera.x,my.x);
		relTilt = clamp(relTilt + 2 * mouse_force.y, -90, 90);
		vec_set(camera.pan, vector(0, relTilt, 0));
		ang_add(camera.pan, my.pan);
		wait(1);
	}
	
}


Also, I found the transitions much smoother when putting "time_step" as the last parameter to alignToVec(...) instead of 1, so you might want to try that out and see if that's what you want.

Lastly, your gravits() function is a little bit risky. I think the first part should be "vec_set(runter.x, vector(0, 0, -20000)); vec_rotate(runter.x, my.pan); vec_add(runter.x, my.x);"
The way it currently is, the direction of the trace depends on the entity's position.

I hope that makes sense and is helpful laugh

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Spherical gravity [Re: JibbSmart] #367747
04/17/11 15:21
04/17/11 15:21
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
OK, so that means that I've fixed another problem then grin
In the demo you showed, player completely can't walk on walls.
I've fixed that as well as I've added smooth camera movement.
Sorry that I've misunderstood main problem.
I thought you can't make camera follow player.
Anyway, Jibbs solution works well. Just make an offset tilt for main one.
So here it is:
Download link
I move camera angles with key forces, change them as you like.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Spherical gravity [Re: 3run] #367768
04/17/11 18:42
04/17/11 18:42
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
@Julz

I LOVE YOU!!!! (NO I´M NOT GAY grin )
THIS WORKS GREAT!! YOU ARE AWESOME!! I´ve spended a lot of time to get this result!
Awesome! Thank you!!



@3run

Thanks! But as my main problem is solved, i think i won´t need it and i already have my script laugh Thanks anyway laugh Maybe i find a way to use it


YOU GUYS ARE GREAT!


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Spherical gravity [Re: alibaba] #367777
04/17/11 21:38
04/17/11 21:38
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
I'm glad it works well grin You're welcome! I hope to see a really cool game come out of this!

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Spherical gravity [Re: JibbSmart] #367794
04/18/11 13:01
04/18/11 13:01
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
One more Question Julz, sorry that i am asking that much.
But i somehow can´t solve this problem.
I want, that my entity gets a target pan angle.
the code is this:

Code:
#include <acknex.h>
#include <default.c>
VECTOR runter;
VECTOR walk_speed;
void alignToVec(ANGLE* entAng, VECTOR* vec, VECTOR* axis, var factor) {
	vec_rotate(axis, entAng);
	vec_normalize(axis, 1);
	vec_normalize(vec, 1);
	VECTOR rotAxis;
	vec_cross(rotAxis, vec, axis);
	var angle =  -acosv(vec_dot(axis, vec))* factor * vec_length(rotAxis);
	ANGLE rotAngle;
	ang_for_axis(rotAngle, rotAxis, angle);
	ang_add(entAng, rotAngle);
}
var oben=0;
ANGLE lo;
void gravitz()
{
vec_set(runter.x, vector(0, 0, -20000)); 
vec_rotate(runter.x, my.pan); 
vec_add(runter.x, my.x);	
my.skill96 = c_trace(my.x, runter.x,IGNORE_ME+IGNORE_SPRITES+USE_BOX+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_FLAG2); // get maniac's height above the floor
	if (my.skill96 > 2)  // if I'm in the air
	{
		oben=1;
		walk_speed.z -= 1*time_step; // gravity force pulls me down
	}
	else	
	{
		oben=0;
		walk_speed.z = 0; // if I'm on the ground, why worry
	}

}

action le()
{
	var relTilt = 0;
	player=me;
	VECTOR temp;
	while(1)
	{		
		gravitz();
		if(key_space&&!oben)
		walk_speed.z=5;
		my.skill9=100*(key_k-key_l);  //Target angle/ 100 or -100
		alignToVec(my.pan, normal, vector(0, 0, 1), time_step);
		c_rotate(my,vector(-ang(my.pan-my.skill9)*0.9*time_step,0,0),GLIDE);
		c_move(my,vector((key_w-key_s)*20*time_step,(key_a-key_d)*20*time_step,walk_speed.z),nullvector,GLIDE | IGNORE_PASSABLE|IGNORE_FLAG2);

		wait(1);
	}
	
}


void main()
{
	VECTOR camang;
	level_load("test2.wmb");
	ent_create("block.mdl",nullvector,le);
	vec_set(camera.x,vector(-100,0,-50));
	while(1)
	{
		vec_set(camang.x,player.x);
		vec_sub(camang.x,camera.x);
		vec_to_angle(camera.pan,camang.x);
		wait(1);
	}
}



What i´ve basically done is calculating the difference in the pan and the target angle and rotate it. But it somehow jerks around, when it´s on a wall.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Page 1 of 2 1 2

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