Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Quad, EternallyCurious, 1 invisible), 726 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simpel explanation about combine c_scan and c_move #308541
02/03/10 16:35
02/03/10 16:35
Joined: Mar 2009
Posts: 21
B
Blackspace Offline OP
Newbie
Blackspace  Offline OP
Newbie
B

Joined: Mar 2009
Posts: 21
Hi

I have some problems with not fully understanding about collision. Some guy gave me some advice to use c_scan and c_move.

I did some research about them and the most stuff I understand. What I don't understand is how to combine them. There was a nice AUM about it but it wasn't in C-lite so it didn't work frown (I don't have enough experience to convert it to c-lite)

What I do know is that c_scan make some area to detect stuff. But I don't know how to trigger a function. frown

Can some one please give a single peace of code that use both c_scan and c_move by turning a model for 90degrees when he is near a wall?

Thx for reading laugh

Re: Simpel explanation about combine c_scan and c_move [Re: Blackspace] #308543
02/03/10 16:37
02/03/10 16:37
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
i you want to turn a model with collision detection use c_rotate wink

Re: Simpel explanation about combine c_scan and c_move [Re: Rei_Ayanami] #308551
02/03/10 17:02
02/03/10 17:02
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
c_scan you don`t need for movement. All you need is c_move and as Rey say c_rotate. If you use this then the collide are enabled. If now a Ent collide with another, the event of both Ents is set. With the mode Flags (IGNORE_SPRITES, IGNORE_MAPS and so on) you can set of what collide your ent reacts.

At your entity action you have to set the Event:
my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); // The event is call if the Ent collide with another Ent or Wall
my.event = your_event; // This function "yous_event()" is calling if the event was happen.

Re: Simpel explanation about combine c_scan and c_move [Re: Widi] #308702
02/04/10 14:49
02/04/10 14:49
Joined: Mar 2009
Posts: 21
B
Blackspace Offline OP
Newbie
Blackspace  Offline OP
Newbie
B

Joined: Mar 2009
Posts: 21
hmmm.. I understand what you say but I don't have the knowledge to turn it in a code. I hope someone can finish my peace of code frown

action guard1()
{
while (1)
{
c_move(me,vector(3 * time_step, 0, 0),nullvector, GLIDE);

if ???? some code when its near a wall ??

{
pan += 90;
}

wait(1);
}}

Re: Simpel explanation about combine c_scan and c_move [Re: Widi] #308707
02/04/10 15:05
02/04/10 15:05
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
The following is a mutiliation of a "c_move sample" found in some version of the manual:
(It is also a fine example of what should not be done.)
Code:
#define _feetZ skill28
#define _inputH skill29
#define _inputX skill30
#define _inputY skill31
#define _inputZ skill32

#define _inputPan skill33	
#define _inputTilt skill34
#define _inputRoll skill35

#define _speedX skill36	// nu
#define _speedY skill37	// nu
#define _speedZ skill38

#define _speedPan skill40
#define _speedTilt skill41
#define _speedRoll skill42

#define _bObst	skill50
#define _jmp skill51


// temp vars galore
VECTOR* ph_v1 = {x=0;y=0;z=0;}
ENTITY* ph_eMe0 = NULL;

ANGLE* ph_aForceR = {pan=0;tilt=0;roll=0;}
VECTOR* ph_vForceE = {x=0;y=0;z=0;}
VECTOR* ph_vForceW = {x=0;y=0;z=0;}

VECTOR* ph_vDistE = {x=0;y=0;z=0;}
VECTOR* ph_vDistR = {x=0;y=0;z=0;}
VECTOR* ph_vDistW = {x=0;y=0;z=0;}

var ph_nFrictZ = 0;

VECTOR* cam_v1 = {x=0;y=0;z=0;}

VECTOR* ob_v1 = {x=0;y=0;z=0;}
ANGLE* ob_a1 = {pan=0;tilt=0;roll=0;}
var ob_nTrace = 0;

var e2f_obtWall(ENTITY* _e, var _nAngle, var _nDist) {
	ob_a1.pan = _nAngle;
	ob_a1.tilt = 0;
	ob_a1.roll = 0;
	vec_for_angle(ob_v1, ob_a1);
	vec_normalize(ob_v1, _nDist);
	ob_nTrace = c_trace(_e.x, ob_v1, IGNORE_ME | IGNORE_PASSABLE | IGNORE_PASSENTS | USE_BOX);
	return(trace_hit);
}

void e1f_new(ENTITY* _e) {
	_e.min_z *= 0.5;
	vec_for_min(ph_v1, _e);
	_e._feetZ = ph_v1.z;	
}

void e1f_move(ENTITY* _e) {
	_e._inputX += _e._inputH * _e._inputX;
	_e._inputY += _e._inputH * _e._inputY;
	vec_set(ph_aForceR, nullvector);
	ph_aForceR.pan = _e._inputPan * 5;
	vec_accelerate(ph_vDistR, _e._speedPan, ph_aForceR, 0.5);
	c_rotate(_e, ph_vDistR, IGNORE_PASSABLE | GLIDE);
	vec_set(ph_vDistE, nullvector);
	vec_set(ph_vDistW, nullvector);
	ph_eMe0 = me;
	me = _e;
	my = _e;
	vec_set(ph_v1, _e.x);
	ph_v1.z -= 5000;
	if (c_trace(_e.x, ph_v1, IGNORE_ME | IGNORE_PASSABLE | USE_BOX)) {
		ph_vDistW.z = _e.z + _e._feetZ - target.z;
	} else {
		ph_vDistW.z = 0;
	}
	me = ph_eMe0;
	my = ph_eMe0;
	if (ph_vDistW.z <= 2) {	// on floor?
		_e._jmp = 0;
		if (_e._inputZ) {
			ph_vDistE.z = (_e.max_z - (_e.min_z * 2)) * _e._inputZ;
			_e._jmp = 1;
		}
	}
	ph_nFrictZ = 0.1;		// default friction
	if (_e._jmp != 0) {	// if jumping, add friction
		ph_nFrictZ = 0.9;
	}
	if (ph_vDistW.z > 0) {
		ph_vDistW.z = clamp(ph_vDistW.z, 0, accelerate(_e._speedZ, 5, ph_nFrictZ));
	} else {
		_e._speedZ = 0;
	}
	ph_vDistE.x = 5 * _e._inputX * time_step;
	ph_vDistE.y = 2 * _e._inputY * time_step;
	ph_vDistE.x = sign(ph_vDistE.x) * (abs(ph_vDistE.x) + 0.5 * ph_vDistW.z);
	ph_vDistW.z *= -1;
	ph_eMe0 = me;
	me = _e;
	my = _e;
	c_move(_e, ph_vDistE, ph_vDistW, IGNORE_PASSABLE | GLIDE);
	me = ph_eMe0;
	my = ph_eMe0;
}

// a player action 
// move with wasd or arrow keys
// jump with space or key_ins
// rotate with mouse
// run with scis..shift
action pl1a() {
	e1f_new(me);
	while(me != NULL) {
		my._inputH = key_shift * 2;
		my._inputPan = mouse_force.x * -1;
		my._inputX = (key_w || key_cuu) - (key_s || key_cud);
		my._inputY = (key_a || key_cul) - (key_d || key_cur);
		my._inputZ = (key_space || key_ins);
		e1f_move(me);
		// bullsh!t camera
		vec_for_angle(cam_v1, my.pan);
		vec_normalize(cam_v1, my.min_x * 5);
		vec_add(cam_v1, my.x);
		vec_set(camera.x, cam_v1);
		vec_diff(cam_v1, my.x, camera.x);
		vec_to_angle(camera.pan, cam_v1);
		wait(1);
	}
}

// ENTITY 2 action
// ENTITY turns in circles (and just by chance, turns away from an obstacle every now and again)
action e2a() {
	e1f_new(me);
	while(me != NULL) {
		my._inputPan = 0;
		my._inputX = 1;
		my._bObst = e2f_obtWall(me, 0, my.max_x * 1.5); // trace every frame
		if (my._bObst) {
			my._inputPan = 1;
			my._inputX = 0.25;
		} 
		e1f_move(me);
		wait(1);
	}
}





Re: Simpel explanation about combine c_scan and c_move [Re: testDummy] #308721
02/04/10 16:35
02/04/10 16:35
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Quote:
if ???? some code when its near a wall ??

Write:
Code:
if(trace_hit)
{
  // do something
}



If your model is colliding with anything, then the stuff inside those brackets will be executed.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Simpel explanation about combine c_scan and c_move [Re: Redeemer] #308769
02/04/10 20:47
02/04/10 20:47
Joined: Mar 2009
Posts: 21
B
Blackspace Offline OP
Newbie
Blackspace  Offline OP
Newbie
B

Joined: Mar 2009
Posts: 21
Thx that did the job grin

It would be nice if there was a Lite-c tutorial about collision and moving for models laugh


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