N
NotNotDragon
Guest
I'm fairly new to GML2 so I was following Shaun Spalding's Action RPG tutorial. When I got to Eps 24 Enemy Basics, I wrote down all the code word for word and double-checked my code many times but the "slimes" don't move at all. They just stay stationary and run their sprite sheet (bobbing up and down). Then when I went back a few videos (because I skipped a few) to do Eps 19 Room Transitions I did the same and copied the code word for word and the rooms just don't change. Can someone help me? (Code Below)
Slime Wander:
Room transitions:
Global variables are done correctly I check many times so I won't post them.
Video Links:
Room Transitions:
Slime:
Hope I can get some help with this.
MOD EDIT: Added code tags to make it easier to read.
Slime Wander:
GML:
function SlimeWander(){
sprite_index = sprMove;
//At destnation of given up
if ((x == xTo) && (y == yTo) || timePassed > enimyWanderDistance / enimySpeed)
{
hSpeed = 0;
vSpeed = 0;
//end move end animation
if (image_index < 1)
{
image_speed = 0.0;
image_index = 0;
}
//Set New Destenation
if (++wait >= waitDuration)
{
wait = 0;
timePassed = 0;
dir = point_direction(x,y,xstart,ystart) + irandom_range(-45,45);
xTo = x + lengthdir_x(enimyWanderDistance, dir);
yTo = y + lengthdir_y(enimyWanderDistance, dir);
}
}
else //Move Twords Next Destenation
{
timePassed++;
image_speed = 1.0
var _distanceToGo = point_distance(x,y,xTo,yTo);
var _speedThisFrame = enimySpeed;
if (_distanceToGo < enimySpeed) _speedThisFrame = _distanceToGo;
dir = point_direction(x,y,xTo,yTo);
hSpeed = lengthdir_x(_speedThisFrame, dir);
vSpeed = lengthdir_y(_speedThisFrame, dir);
if (hSpeed != 0) image_xscale = sign(hSpeed);
//Colide and Move
EnimyTileCollison();
}
}
GML:
if (instance_exists(oPlayer)) && (position_meeting(oPlayer.x,oPlayer.y,id))
{
global.targetroom = targetRoom;
global.targetx = targetx;
global.targety = targety;
global.targetDirection = oPlayer.direction;
room_goto(targetRoom);
instance_destroy();
}
Video Links:
Room Transitions:
Hope I can get some help with this.
MOD EDIT: Added code tags to make it easier to read.
Last edited by a moderator: