Scripts / How to say avoid collision to an object in LUA ?

Author
Message
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 29th Jul 2021 14:39
Hi to everyone,
i have my object, in LUA how to say to my object
if object is too close to x object avoid collision ?

thanks
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Jul 2021 18:08
CollisionOff( e ) will turn off physics for the object.


Been there, done that, got all the T-Shirts!
PM
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 30th Jul 2021 06:21 Edited at: 30th Jul 2021 06:29
i mean if the object is too close to another how to avoid the collision by making the moving object to bounce at some distance
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/

Attachments

Login to view attachments
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 30th Jul 2021 13:27 Edited at: 30th Jul 2021 13:28
Dynamic physics objects will bounce off auomatically, non-physics objects (like ones you are explicitly moving yourself via scripting) will not so you will have to 'fake' it using a bit of math.

i.e. calculate the angle of collision and move the entity appropriately.

How is you vector math skills?
Been there, done that, got all the T-Shirts!
PM
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 30th Jul 2021 16:14
"How is you vector math skills?"........... hahaha best joke of the year....
zero i think ... not sure lol
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 31st Jul 2021 05:06
Sounds pretty much like "breakout" ya know those brick games
on DOS that started in the 80's. Arkanoid was a famous one.
Was working on a GG breakout experiment script earlier this year.
Really just like it looks-- reverse the trajectory against the 4 quadrants.

In your case, with the diagram you showed, you might want to try
a repelling method. If it's close, it just moves in the opposite direction
as it would if it faced the object. Simple. You have the follow player
script, now just reverse it.

Bonus: This "move_away" script exists already in the "objects" sub folder.
PM
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 31st Jul 2021 09:34 Edited at: 31st Jul 2021 09:39
well how to add that move away to my code actual code ?


actually i have an entity who always look at the player & move in his direction but the entity stay stuck on my object walls and i try to avoid the entity to stay stuck by the walls
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 31st Jul 2021 09:45
it has to be a way to trace a path to the player who calculate the shortest way to the player position
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/

Attachments

Login to view attachments
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 31st Jul 2021 18:44 Edited at: 31st Jul 2021 18:47
The only way to script that is to allow the AI to "see" the layout of the obstacle course in a broad pattern. This is a highly complex situation and one that even GG developers are still working out in their path-finding feature.
I'm not sure if you have tried some of their AI now, I don't know how it is computed or if it's hard-coded as when a level loads, there is a "AI path-finding" notification. On my old computer, that used to be the longest part of loading a level when I actually made maps so I really wondered what in the world that was?! Now on my new computer I can't even see that part pop up- and I only use empty maps to test scripts. We'll see if they do something to release that work for users?

Yeah, one reason multiplayer is a key feature as it places the most complex, 5 senses, pre-made thinking machine in existence into the game. And humans are a survival based, competitive creature.
PM
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 1st Aug 2021 15:26 Edited at: 1st Aug 2021 16:18
well actually im pretty close to have something good, i just need to make the entity following me to bounce on my walls if the entity is too close to the wall,corners

the problem is the entity move in straight lines, i need to make his movement sinusoidal, but i'm not good at that !

i don't know if it's possible to make the entity change his moving speed, like sometimes slower ?
in my script i have this for the speed:
local moveSpeed = 250
but it's constant, always the same is it possible to vary the speed ?

this is my first result:

i was playing/testing & changing things in my actual script made by AmenMoses and i'm close to something good, the entity follow me all the time even if i go on upper levels, it's horrible lol

but i need to vary the speed & also i need to avoid the entity stay stuck on walls/corners
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 1st Aug 2021 17:18
As I mentioned, to get 'living' type behavior you would have to program a small
brain into your script-- many dozens of lines of code. The whole industry is just
getting this pretty well figured out with self driving cars-- just now with $Millions
in research. I see if you keep the follower close, there's not too much issue.

"but it's constant, always the same is it possible to vary the speed ?"
Certainly possible, but who's to say why or when it moves slower or faster?
What determines that? Seems like more chance to get hung up behind walls.

Also, what's the context? I'm going to have a pet animal following my character
in my game-- we'll see how that goes.
PM
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 1st Aug 2021 18:13 Edited at: 1st Aug 2021 18:13
i dont need a "living" behavior just following the player that part is almost complete, now i'm stuck with the bouncing process, the entity need to "bounce" when collide with the wall
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 1st Aug 2021 19:30 Edited at: 1st Aug 2021 19:33
it has to be a function who make an entity to bounce on collision !
on this screenshot we can see the entity stuck in the corner wall happens 99% of time
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/

Attachments

Login to view attachments
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 2nd Aug 2021 03:38
There's not a function as far as I know. I drew a grid with pen and pad and over a
couple days of hard work, thinking, testing and re-testing mimicked ricochet behavior.
That was probably on my old computer since handed down.
A better visual method might be to walk into the walls to wall in a small room holding a
compass and writing notes in every direction. It might sound weird but it's a visual method.
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Aug 2021 17:52
use the AI logic so it will path around the walls and then it won't need to bounce off the walls at all.
AI logic is not beginner friendly in GG but it's what you are looking for with this
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 2nd Aug 2021 18:37 Edited at: 2nd Aug 2021 18:38
The only way of getting a proper bounce is to use a physics object and push it around rather than trying to mimic it yourself.

What I would do is use AI logic to move a small invisible entity around the maze then have a visible physics entity being pushed in the direction of the AI entity, you would need to adjust the speed of the AI entity so it doesn't get too far away or have the physics entity overtake it though.

I managed to get the scifi drones working reasonably well after a bit of faffing about with the script. They won't bounce off walls obviously as the AI code makes them avoid objects.

Been there, done that, got all the T-Shirts!
PM
imothep85
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 4th Aug 2021 08:10
whaouw AmenMoses so you did it?

this one is very nice
[video=vimeo]https://vimeo.com/user54473706[/video]

where can i find that script if it's free ?
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
AmenMoses
GameGuru Master
8
Years of Service
Recently Online
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 4th Aug 2021 09:32
If you have the scifi pack you already have the basic script.
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-04-20 12:04:09
Your offset time is: 2024-04-20 12:04:09