• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Player score increments not by one but by multiples

R

Ragedleinad

Guest
Hi team, I have come across a issue when I want to increment the players score when interacting with other object, it increments sometimes by 1 , 2 or 3, here is the snippet

Code:
with(other){
    speed=100;
    oPlayer.peopleScore+=1;
    direction=170;
    

}
This is when there is a colittion with the object, I do not want to destroy the other instance but only change the direction to up, so maybe it is hitting my object twice and that's why it is counting double/triple?

Best regards
 
S

Sinaz20

Guest
If you don't have any code to move oPlayer out of the colliding object when the collision is detected, then it will continue to collide each step until it has moved clear of that object.

After detecting a collision, after you set direction, you could use move_outside_solid/all() to get the object in the clear, though... i don't know what your movement looks like-- but a solution typically used in perfect collision would be better. There are tons of code examples replicating how solid collisions are supposed to work on the forums.
 
N

nicoltoons

Guest
with(other)
{
speed = 100
//create a variable in oPlayer eg collide= false in the create event.
if oPlayer.collide == false
{
oPlayer.collide = true
oPlayer.peopleScore+=1 //this should just add once
direction = 170
}
}

if you want the player to collide again, at some point maybe out of reach of the second object, set it back to false
 
Top