Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
elevator problem #368847
04/28/11 21:46
04/28/11 21:46
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline OP
Senior Member
xbox  Offline OP
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
Hi all, I am trying to create a simple elevator to lift my player up to the next level. I have a mock up code to do this.
Code:
Entity* elev;
var operate = 0;
action elevator
{
	elev = my;
	while(1)
	{
		if(operate == 1)
		{
			while (my.z > -72)
			{
				my. z -= 2* time;
				wait(1);
			}
		}
		if(operate == 0)
		{
			while (my.z < 72)
			{
				my.z += 2 * time;
				wait(1);
			}
		}
		wait(1);
	}
}

What happens is, my elevator poses as a "wall", when I change variable to 1, it lowers to the ground, I walk onto it, change the variable to 0, and instead of taking the player up, the player just passes right through the block as it moves up leaving me still on the first floor.
If I hold down the space bar to continually jump however, I am able to ride the elevator up. How can I fix this so I don't have to jump?

Re: elevator problem [Re: xbox] #368864
04/28/11 23:45
04/28/11 23:45
Joined: Feb 2010
Posts: 68
mireazma Offline
Junior Member
mireazma  Offline
Junior Member

Joined: Feb 2010
Posts: 68
I think that code has nothing to do with player/elev collision. Excuse me for modifying your code - still not solving your problem - but I'd avoid wait() as it's not fast at all and nested while loops are not necessary here.
Code:
Entity* elev;
var operate = 0;
action elevator
{
	elev = my;
	while(1)
	{
		if(operate == 1 && my.z > -72)
			my. z -= 2* time;
		else	
		if(operate == 0 && my.z < 72)
			my.z += 2 * time;
		
		wait(1);
	}
}


And elev pointer is not used grin

I don't understand: is there at least a situation when the player collides with the elevator?
when you say "I walk onto it" does it mean you are raising your z?
"I am able to ride the elevator up" you can stand on the elev. when you jump on it and it's in mid-air?


ERROR in communism.cpp, line 0:
#include<god.h>
was fatally missed.
Re: elevator problem [Re: mireazma] #368865
04/28/11 23:52
04/28/11 23:52
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline OP
Senior Member
xbox  Offline OP
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
yes the player is touching the elevator, by standing on it. Once standing on it, the elevator should start moving on the z axis upward. In doing so, the players z value should also rise with the elevator.
When I jump, while standing on the elevator, the player z value is also raised.
When I stop jumping, the player sinks through the elevator and falls to the bottom floor, and the elevator continues moving upward.

Re: elevator problem [Re: xbox] #368871
04/29/11 03:54
04/29/11 03:54
Joined: Jan 2011
Posts: 120
United States
Logan Offline
Member
Logan  Offline
Member

Joined: Jan 2011
Posts: 120
United States
I think you need to use c_move() instead. I've never written elevator code so I'm not sure exactly how it would work but try playing with c_move and the entities' push values.

Re: elevator problem [Re: Logan] #368902
04/29/11 11:42
04/29/11 11:42
Joined: Feb 2010
Posts: 68
mireazma Offline
Junior Member
mireazma  Offline
Junior Member

Joined: Feb 2010
Posts: 68
So it seems that there's no collision implemented. Logan's right. You could try c_move for the player (make sure that elev PASSABLE is reset) or as alternatives handle the player z yourself:
1. use c_trace, determine if the underlying object is the elev.
Got it from the manual
Code:
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME|IGNORE_SPRITES|IGNORE_CONTENT);
  my.z = hit.z - my.min_z;


or

2. find a way to define if the player is in the elev xy range and has z > elev.z.
In either case, all you have to do is use
Code:
player.z = elev.z + elevToPlayer //elevToPlayer is your adjustable var.


Don't forget to modify elevToPlayer in the jump code, if any.

Note that (1.) or (2.) should be handled by an event so as not to use c_trace or "if" respectively, all the time even when you're far away from the elev. If you're using c_trace anyway to handle player z in general, the better.
I'm a beginner myself and idk if you can define custom events.

You can also put the code in elev action:
A. make operate 0 for idle state.
B. if operate != 0
B. if c_trace (use USE_BOX to cover the whole elev area) hits an entity, set its z or check (2.) now, from here.

In either case note that you have to write the code for every entity that can be lifted by elev.
In my previously used SDK you could use inheritance and could make a parent class that contained the common entities coding.
No idea if you can with 3DGS but most chances are that you can

There may be easier ways and faster ones (not the same!) but I'm a 3DGS beginner and that's what I could come up with now.

Last edited by mireazma; 04/29/11 11:52.

ERROR in communism.cpp, line 0:
#include<god.h>
was fatally missed.
Re: elevator problem [Re: mireazma] #368907
04/29/11 12:11
04/29/11 12:11
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
There is a good elevator example in AUM's shooter templates.
BTW, do you need this for our project? If yes, PM me.


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

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