[feature request] Within distance block?

Could they add a within distance block
distance
(it could give distances of any thing in it)
and
closes to
from list

and maybe a lock to block
I had to make hundreds of block
to get a gun just to stay in the same spot on a ship

Please provide examples (blocks / screenshots / drawings) for where you need this ( I am guessing on the canvas?)

yes, that would were it would be for most senses

Discussion about how to determine the distance between two objects on a Canvas:

might help Jaxon,.

1 Like

what about the lock to block?

And yes that did help

An imageSprite will generally only move if you move it. As previously suggested give an example of what you mean.

Scott Ferguson did somethig similar to make a Ball carry a number Sprite.
Look in his Developers Library in the CAnVAS FAQ.

1 Like

I do not know how to get to the Developers Library
I looked around and could not find it

you can fid it here https://groups.google.com/g/app-inventor-developers-library/search?q=canvas
Taifun

The Scott Ferguson Developers Library was, unfortunately, a wild goose chase.
The original sample must have been posted in one of the predecessor App Inventor boards.

I searched my converted App Inventor Classic .aia files, and found a working sample ...
number on ball demo


number_ball_with_visibility_tweak.aia (4.0 KB)

ball_tracker_clk
Clock1


Text_Delay_Clock




when Balle EdgeReached

Unfortunately, some of the critical settings were done in the Designer, so import the .aia and double check it.

The basic idea here is to dynamically draw the text in a small Canvas, capture the image of the Canvas, and use that image in a small Sprite. Have a separate Clock track the Ball and move the sprite onto (higher Z) the moving Ball.

1 Like

Simple way to calculate distance within a Canvas and to determine nearest. Very simple way to attach a Ball to a Sprite.

1 Like

the lock to location is the easy part

gun_place_test_checkpoint1.aia (666.1 KB)

the part I used to lock to a offset part of a sprite or ball and rotation is procedure1
and both of them use hundreds of blocks

This can be reduced to a little trigonometry, once you have the measurements of the plane carrying the guns and its gun mounts.
Have you studied trigonometry yet?

1 Like

no not yet. but is it the kind of stuff that was used to determine distance

I looked it up and yes.

Also

1 Like

Have you considered duplicating your picture of the plane with variations of guns mounted on it, to avoid having to track the plane's gun mounts?

Alternatively, you could stamp multiple images onto one another at run time in a separate Canvas, taking Canvas images with the guns mounted, and using the resultant image file as the picture of your plane sprite.

That would avoid all the trigonometry.

but then the gun can't turn and all shots would have to only be from center

how would I do it with the distance/ translate it into a x and y at different angles