Build Man
Member
I am back. So , here is the next problem I am stuck with. It's about platforms.
The thing is, I thought a certain tutorial could help me make a platform, but it uses entirely different movement and collision mechanics. And then there's Shaun Spaulding's platform tutorials. While one-way static platform tutorial proved helpful and worked almost perfectly, the moving platform one turned out to be a sham. So was not much helpful.
The main problem is with vertical platform one. When protagonist land s on it, he totally blocks it's upward movement. And when platform moves down, protagonist rapidly lands on a platform rather than standing still. I need Protagonist to... *computer noises* ..."stick" to the platform, moving up and down when platform does so.
Here are the codes:
In Create event, I have this piece of code.
"angle" is from first attempts at creating moving platform, and is not used, because in-room Creation Code for individual object does not account object's own Create event variables in. "vel_increment" was "angle_increment" before, and "velocity" was "angle_multiplier".
In the Step event, I have this.
The result of trying to make platforms funct without relying on multiple copies of object(for Horizontal and Vertical movement).
if horizontal = 1
x += cos(gravity_direction) * velocity
if vertical = 1
y += sin(gravity_direction) * velocity
This part is taken from aforementioned(and linked) first tutorial. User defined events for this to work are...
And this part is taken from platform_parent Object. The event of Collision with Protagonist.
I think I have covered everything. Now it is up to you to tell what needs to do.
The thing is, I thought a certain tutorial could help me make a platform, but it uses entirely different movement and collision mechanics. And then there's Shaun Spaulding's platform tutorials. While one-way static platform tutorial proved helpful and worked almost perfectly, the moving platform one turned out to be a sham. So was not much helpful.
The main problem is with vertical platform one. When protagonist land s on it, he totally blocks it's upward movement. And when platform moves down, protagonist rapidly lands on a platform rather than standing still. I need Protagonist to... *computer noises* ..."stick" to the platform, moving up and down when platform does so.
Here are the codes:
In Create event, I have this piece of code.
Code:
//WARNING
//To change these, use "Generate Code" function on the object you placed in Room.
//Access "Generate Code" by CTRL+RMB on a desired object.
angle = 0
vel_increment = 0.1
velocity = 1
horizontal = 0
vertical = 0
In the Step event, I have this.
Code:
//Allow Protagonist to jump through from below.
if ((Protagonist.bbox_bottom) < y)
mask_index = -1;
else
mask_index = platform_wood1_short
Code:
vel_increment = image_speed
gravity_direction += vel_increment
if hspeed != 0
{
event_perform(ev_other,ev_user0)
velocity = hspeed
hspeed = 0
}
if vspeed != 0
{
event_perform(ev_other,ev_user1)
velocity = vspeed
vspeed = 0
}
if horizontal = 1
x += cos(gravity_direction) * velocity
if vertical = 1
y += sin(gravity_direction) * velocity
//This code defines if it's Horizontal moving platform, or Vertical one.
//Speed is set via CTRL+RMB on a platform and choosing "Creation Code".
if horizontal = 1
x += cos(gravity_direction) * velocity
if vertical = 1
y += sin(gravity_direction) * velocity
This part is taken from aforementioned(and linked) first tutorial. User defined events for this to work are...
Code:
horizontal = 1
Code:
vertical = 1
Code:
with other
{
if (place_meeting(x,y+vspeed,platform_parent))
{
while(!place_meeting(x,y+sign(vspeed),platform_parent))
{
y += sign(vspeed);
}
vspeed = 0;
}
if(place_meeting(x+hspeed,y+vspeed,platform_parent))
{
while(!place_meeting(x+sign(hspeed),y+sign(vspeed),platform_parent))
{
x += sign(hspeed);
y += sign(vspeed);
}
hspeed = 0;
vspeed = 0;
}
}
The next topic of the thread is Horizontal Platforms(and Vertical ones when they go upward) having way more friction than they should, severely slowing Protagonist down. It is not in a separate thread because this problem followed immediately afterwards.
Last edited: