I’m making this game, but when I use clones for the “sticks”, it lags up when coming near the object…any ways to get it unlaggy?

https://c.gethopscotch.com/p/104xpstyfp

# Laggy Code Help

No the sticks are the stick figures

The line and triangle are obstacles

This project was just a test for the lag

**ThinBuffalo**#6

The native Bumps rule causes lag. You have to make a conditional rule using math instead…

So the collision is between the stick figure(s) and the slanted line or triangle, or both?

Do you want a collision anywhere on the stick figure to register, or just on the feet for example?

Anywhere on the stick for collision

For now the collision is the triangle

I’ll try the conditional rule

**ThinBuffalo**#8

How accurate does the collision need to be? I.e., is a “bounding box” around the triangle ok, or do you prefer for a part of the stick figure to be precisely in the triangle?

When it’s just inside the triangle

Could you do it with clones of triangles too?

**ThinBuffalo**#10

The short answer is yes, but that makes it a lot more complicated (and it’s not a walk in the park to start with)

How much harder it gets depends on more Q&As…

- How many triangle clones are you talking about?
- Does the collision rule in your application need to update every frame?

It would be up to 10 triangle clones and yes

Sorry if I’m making this hard

**ThinBuffalo**#12

The collision for the stick figure will need to be for a bounding box since it’s not a regular shape, that ok?

Looks like it would fit in a rectangle reasonably well…

Also, will the triangle(s) always be an equalateral triangle (the specific triangle you’ve used in the test project) with rotation 0? That affects the collision math…

Yeah I think I have the collision box here

https://c.gethopscotch.com/p/104xuvdh5

Wait I messed up on an equation

And the triangle will always be an equilateral triangle

**ThinBuffalo**#18

I’m about out of available time for now, but position data for all of the triangle clones needs to be passed to all of the stick figure clones. The only way I can think of at the moment to do that *every frame* is a whole bunch of global variables. Each triangle clone would be hard coded (using nested conditionals) to use specific variables.

Then the stick figures would need a specific rule for every triangle clone that’s tailored to the clone’s global variables.

…I warned you that it’d be complicated. Unfortunately, all that tedium is necessary because THT hasn’t seen fit to provide a mechanism to directly access a specific clone’s traits & object variables by its clone index (I’ve asked). Meaning, more sophisticated languages have object collections (analogous to clones) and you can reference any object’s properties with syntax like this: Triangle(index).property

A walkthrough or basic tutorial (if you can call it that) would be amazing help if you don’t mind (I’ll definitely give you major credit) as I’m not old enough to know a few blocks of math.

EDIT: 99 percent sure I Figured it out thanks for your help!

@William04GamerA this problem is solved just have to remove tags

Aah sorry I tagged Code help