(REQUEST) How to Make a Rubberband!

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
IttaBaby
Swooper
Swooper
Posts: 53
Joined: Sat Apr 08, 2017 8:19 pm

(REQUEST) How to Make a Rubberband!

Postby IttaBaby » Thu Feb 28, 2019 1:22 am

I wish to make a chase NPC that does not fall behind enough to trivialize him while making him slow down when close to give the player some time to get around obstacles.


On another note, should there be a request thread/board/ect. to keep me from spamming this place? I feel bad when I ask for help rather than contributing. :/

The Dwarven Digger
Lakitu
Lakitu
Posts: 484
Joined: Sun Oct 30, 2016 11:17 am
Pronouns: they/them

Re: (REQUEST) How to Make a Rubberband!

Postby The Dwarven Digger » Sat Mar 02, 2019 4:54 am

I think I could help, but I'll need some more information first.
1) How will this NPC chase the player?
2) Will they copy the player's movements or continually move in a single direction?
3) Will they pass through blocks ,overcome the obstacles themselves or just break through the obstacles?

IttaBaby
Swooper
Swooper
Posts: 53
Joined: Sat Apr 08, 2017 8:19 pm

Re: (REQUEST) How to Make a Rubberband!

Postby IttaBaby » Sat Mar 02, 2019 2:43 pm

Currently he's just a re-skinned spiny, so walking forward while you make it around terrain. But having him break the terrain too would be cool.

The Dwarven Digger
Lakitu
Lakitu
Posts: 484
Joined: Sun Oct 30, 2016 11:17 am
Pronouns: they/them

Re: (REQUEST) How to Make a Rubberband!

Postby The Dwarven Digger » Sun Mar 03, 2019 8:27 am

Could you also PM me a download link for the level and any custom graphics etc. that go with it? If I have the layout that will help see how the NPC will have to behave and what obstacles there are, which could affect how the code works.

Hoeloe
Foo
Foo
Posts: 1463
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: (REQUEST) How to Make a Rubberband!

Postby Hoeloe » Sun Mar 03, 2019 9:02 am

Just as a note, I've used rubber banding techniques previously, and created an equation to determine the speed of a rubber banding object:

speed = s*(S/s)^(d/D)

Where:
S is the maximum speed of the camera (i.e. player runspeed)
s is the minimum speed of the rubber band
D is the maximum distance the rubber band can be from the player
d is the current distance the rubber band is from the player

And obviously, * is the multiply operator, / is the divide operator, and ^ is the power operator (in Lua that's math.pow).

This creates an exponential rubber band that slows down as it gets close to the player, but ensures it never gets more than a specified distance away. How to actually implement this is up to you, but the equation is there should you want it.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari