Discuss Scratch

Koamodo975
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

I'm making a top-down game that features boomerangs (similar to a certain game that Scratch won't let me type the name of Boomerang Kung-Fu minus the first part of kung-fu ), but I STILL don't know how to create a boomerang effect. This one can be semi-realistic: Throwing the boomerang launches it with air resistance and velocity, and if it hits something it bounces off at a realistic angle (e.g., throwing it at a 45 degree angle into a flat wall bounces it off at a 135 degree angle). After a certain period of time it begins trying to return to the thrower, bouncing around until it reaches them.

Last edited by Koamodo975 (June 26, 2024 19:31:40)

Koamodo975
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

Okay, I now know how to calculate the angle transition if the boomerang bounces:
{pre-collision angle of ball} - {angle of wall plane} = {post-collision angle of ball}
But how do I figure out the angle of the wall? The stage will most likely be one sprite.
Icefan13
Scratcher
100+ posts

How do I create a semi-realistic boomerang?

Dunno about the wall reflections, but for everything else:
when I start as a clone
go to [sprite that's throwing this v]
point in direction ([direction v] of [sprite that's throwing this v])
set [speed v] to (10)
forever
move (speed) steps
change [speed v] by (-1)
if<(speed) < (0)>then
point towards [sprite that's throwing this v]
turn cw (180) degrees
if <touching [sprite that's throwing this v]?> then
delete this clone
end
end
end
Koamodo975
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

bump
Koamodo975
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

bump
Koamodo975
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

Bump
Koamodo975
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

bump
awesome-llama
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

Koamodo975 wrote:

But how do I figure out the angle of the wall? The stage will most likely be one sprite.
If using exclusively sprite-based collision detection (which I don't recommend), you can look at Griffpatch's YouTube ball physics tutorial. His method is to make the ball scan the surroundings when it collides with the surface to approximate where the surface is and what its normal is.
(a normal is a vector pointing perpendicularly away from a surface)

The more accurate method would be to represent the obstacles using mathematical primitives such as points and line segments. I did this in my Mini Golf game. These primitives allow you to directly calculate their normals, intersection points, etc.
Koamodo975
Scratcher
1000+ posts

How do I create a semi-realistic boomerang?

awesome-llama wrote:

Koamodo975 wrote:

But how do I figure out the angle of the wall? The stage will most likely be one sprite.
If using exclusively sprite-based collision detection (which I don't recommend), you can look at Griffpatch's YouTube ball physics tutorial. His method is to make the ball scan the surroundings when it collides with the surface to approximate where the surface is and what its normal is.
(a normal is a vector pointing perpendicularly away from a surface)

The more accurate method would be to represent the obstacles using mathematical primitives such as points and line segments. I did this in my Mini Golf game. These primitives allow you to directly calculate their normals, intersection points, etc.
Alright; I'll look into both. I feel like griffpatch's would be easier, as I don't need too much accuracy and am not adding gravity.

Powered by DjangoBB