I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: Vitellari on November 10, 2015, 02:47:04 AM

Title: I need help
Post by: Vitellari on November 10, 2015, 02:47:04 AM
I want to make that a block, when the kid touches a trigger, the block moves to a X position, for example, 1 block to the right. If you can help me, It would be very helpfull :)
Title: Re: I need help
Post by: infern0man1 on November 10, 2015, 07:20:18 AM
Set an alarm in the block that goes off when the kid touches the trigger, and when it reaches a certain coordinate, reset it's speed.

I'd do it like so:

Code: [Select]
//step
if(global.trigger[num]=true){
  alarm[0]=1;
}
if(x>=coordinate]){
  x=coordinate;
  speed=0;
}

//alarm 0
speed=[speed];

There's probably a better way to do this, but yeah, it should work
Title: Re: I need help
Post by: Vitellari on November 10, 2015, 10:13:17 AM
It didn't work :(
Title: Re: I need help
Post by: BaronBlade on November 10, 2015, 01:39:50 PM
It didn't work :(

What exactly did you try? There are a few ways that you could have put something in incorrectly. Some screenshots or at least a description would help.
Title: Re: I need help
Post by: Arclooper on November 10, 2015, 02:18:36 PM
It could be a difference in how the engines handle triggers if you're not both using the same one, I don't know if they all do it the same way, so you could check that.

You could also put variables for the position and speed in the create event, and if your triggered object can act in different ways other than this, also put a variable so it only moves like this when you set it to true, like:
Create
Code: [Select]
xx = 0
yy = 0
spd = 0
move = false
//you can change these in the instance's creation code to the values you want to use
Step
Code: [Select]
if triggered == true and move == true
{
if point_distance(x,y,xx,yy) > speed
{move_towards_point(xx,yy,spd)}
else
{
x = xx
y = yy
speed = 0
}
}
And if you meant for it to move instantly to the position you want simply do this in the step
Code: [Select]
if triggered == true and move == true
{
x = xx
y = yy
}
You would prolly still need to check for how the engine you're using deals with triggers though, just to be sure