Laggy Code Help

#1

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

5 Likes
#2

Is the sticks that slanted line on the ground?

2 Likes
#3

No the sticks are the stick figures

The line and triangle are obstacles

This project was just a test for the lag

#4

They’re all clumping together

1 Like
#5

Because it’s like a wave they are supposed to do that

#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?

5 Likes
#7

Anywhere on the stick for collision

For now the collision is the triangle

I’ll try the conditional rule

1 Like
#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?

3 Likes
#9

When it’s just inside the triangle

Could you do it with clones of triangles too?

1 Like
#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?
3 Likes
#11

It would be up to 10 triangle clones and yes

Sorry if I’m making this hard

1 Like
#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…

3 Likes
#13

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

1 Like
#14

With rotation 0?

3 Likes
#15

Yeah

Got the equation right now going to try clones

1 Like
#16

Ok, tag me when or if you want more input

3 Likes
#17

Help with the clones would great

#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

4 Likes
#19

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!

#20

@William04GamerA this problem is solved just have to remove tags

Aah sorry I tagged Code help

2 Likes