One-Block point towards and Lagless when bumps

Is there a way to make an object point towards somthing using just one block? And is there a way to detect when something touches something else when there are lots of clones and without lag? Thanks.
@CodeHelp.

8 Likes

Game starts-
Set position X(object’s self X position —number) Y (self Y position)

This prob didn’t help, because you an amazing coder and you’re WAY better than me at this lol

5 Likes

I’m not sure, sorry.

4 Likes

I’m not that great. Thanks though.

3 Likes

Ye you great!
No problème

3 Likes
  1. No, not that I know of.
  2. Possibly.
1 Like

Is there a way to make an object point towards somthing using just one block?

Yes.

If you look in my Rubik’s Cube project, you’ll find some abilities called ATAN2. It has 2 nested conditionals, so it isn’t literally 1 block. But each code path has only one block, so if you’re worried about lag, it executes in the same time as one block. Change the blocks to Set Angle.

A single equation, without the nested conditionals, can also be derived using Dot Product if you really need just 1 block.

And is there a way to detect when something touches something else when there are lots of clones and without lag?

Yes. There’s been other topics/discussions about this. In general, you’d create either a circular or square zone (depending on the image shape) that triggers a When < rule.

5 Likes

See my games like Zombie Run and Flight of the Turkey.
I mainly use square collisions where absolute value (obj_x-obj2_x)<(hitboxwidth) and same with Y values. You’ll have to test the hitbox a few times though. Zombie Run has ~250 objects and most of my other games has 30 objects.

2 Likes

I know how to do the colissions but it has lots of lag!

2 Likes

Thanks! That is really helpful, but I have lots and lots of clones which need to test if they are touching any other clones simultaneously. I don’t think that that would quite work.

Edit: There are lots of ‘ATAN2’s and they all require a check if else. What I was trying to say was that I needed a single block as in a single ‘set angle’ block.

2 Likes

Why do you need 1 Set Angle block? Read this again:

I can give you a formula for 1 Set Angle block but it won’t change anything.

https://c.gethopscotch.com/p/zz0xd1rd9

3 Likes

I think they would know about the “When ( ) bumps ( )” when already.

clones which need to test if they are touching any other clones simultaneously

For that you need to use the built in When Bump rule and accept the lag

Wow! Thanks, that is exactly what I needed!

1 Like

I use that all the time

1 Like

Well I just made a project and I used Jeff3321🇳🇱‘s code and I did this


Check the “collisions” rule in “square 2”!
@MISSION_IMPOSSIBLE hope this helps!

1 Like

Me too! I used it for tons of projects, and I learned how to do it by checking a game in featured, I think it was something like “target practice”

Thanks everyone! This will be helpful.

1 Like

Hmmm… I am just wondering… is there a way to do a move forward without changing the angle? I need a way to use a set position block to move lots of objects in lots of different directions without changing the angle of the object.
@CodeHelp

7 Likes
Set Position X [ (self)speed/40 * COS((self)angle) + (self)x_position ], Y [ (self)speed/40 * SIN((self)angle) + (self)y_position ]

where, (self)angle is a new object variable that you set instead of changing the object’s rotation

note: Speed is divided by 40 since the a Speed of 400 moves 10 pixels each frame with the Move Forward block.

9 Likes