Author Topic: I need help  (Read 1755 times)

Vitellari

  • Wannabe
  • Posts: 10
  • Wandering Around Aimlessly
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 46.0.2490.80 Chrome 46.0.2490.80
    • View Profile
  • Playstyle: Keyboard
I need help
« 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 :)
VVVVVV

infern0man1

  • ~(=^・ω・^)ψ
  • Global Moderator
  • Oatmeal Killer
  • Posts: 1.021
  • Dear sir stroke madam, fire exclamation point
  • OS:
  • Android 4.4.2 Android 4.4.2
  • Browser:
  • Chrome 46.0.2490.76 Chrome 46.0.2490.76
    • View Profile
    • Twitter
  • Playstyle: Keyboard
Re: I need help
« Reply #1 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

Vitellari

  • Wannabe
  • Posts: 10
  • Wandering Around Aimlessly
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Firefox 42.0 Firefox 42.0
    • View Profile
  • Playstyle: Keyboard
Re: I need help
« Reply #2 on: November 10, 2015, 10:13:17 AM »
It didn't work :(
« Last Edit: November 10, 2015, 01:02:24 PM by Vitellari »
VVVVVV

BaronBlade

  • Spike Dodger
  • Posts: 140
  • bees?
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 46.0.2490.80 Chrome 46.0.2490.80
    • View Profile
  • Playstyle: Keyboard
Re: I need help
« Reply #3 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.
bean!

Arclooper

  • Wannabe
  • Posts: 26
  • The plot chickens
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 42.0 Firefox 42.0
    • View Profile
  • Playstyle: Gamepad
Re: I need help
« Reply #4 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
« Last Edit: November 10, 2015, 02:21:46 PM by Arclooper »