Simple score system

Im working on a really small game where you are a magnet and you float through a level gattering
Ragdolls humanoids (the magnet atracts rigidbodies)

But i want it to at one point to my score for each ragdoll you gatter(you try to gatter all the ragdolls at once(you drag them behind you))

When you enter the end of the level(collider)
I want it to count all the ragdolls in the collider and at the points to my score

But i dont know how to code it

Im at

Public float Point = 1f;

If(other.tag = ragdoll

Not real code! Example

(This is not what my code looks like in c#)

But this only adds a couple of points if all the ragdolls are entering the collider, not all the points like i want it to

Also it wont let me chose the right topics
Not a single letter works


needs to be

point = point +1;

right now all you’re doing is making the number 1 every time you collide, you need to tell it to increase by 1 every time you collide.

just replace point in the ifstatement with point++;

Alright thanks

Then one more question

Same game

I am able to switch scenes and all

So one scene is singleplayer

Second scene is local multiplayer(one pc)

I have 2 spheres
Both with a code

One code
Gets the rigid body of the sphere
And if i press an arrow key it will add force in that direction

The other one does the same but instead of arrow keys it uses WASD

But when i press W both spheres move up
They also atract one another
I have been thinking of a differend code without rigidbody then they wont atract each other but then when i press W or ASD it moves through the inviroment


Practically speaking you should store the score in something like a game manager but for what you are trying to do this should work. Just attach it to your player and add a collider marked as trigger.

public int totalPoints;

// add a point if a GO tagged as "Ragdoll" enters the trigger.
void OnTriggerEnter()
    if (other.tag == "Ragdoll")
        totalPoints += 1;

// Remove a point if a GO tagged as "Ragdoll" leaves the trigger.
void OnTriggerExit()
    if (other.tag == "Ragdoll")
        totalPoints -= 1;

Then it just depends how you get the score. You could do something like Player.GetComponent<ScriptName>().totalPoints from whatever script is in control of the end game stuff.