Scripts / script follow player

Author
Message
imothep85
15
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 23rd Jul 2021 19:32
hi i would like to achive this simple script, an object, any 3d object who follow the player how can i do that?
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
AmenMoses
GameGuru Master
5
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Jul 2021 20:00
Basically just turn towards the player and move forward as long as the entity is greater than a specific distance from the player.
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
5
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 23rd Jul 2021 20:58 Edited at: 23rd Jul 2021 20:59
So there is a bit of a catch-22 situation in GG atm.

With physics on the RotateToPlayer functions don't appear to work for simple entities like the crate.
With physics off the MoveForward function doesn't appear to work!

So you can make crate rotate to the player if it has physics off but it can't move towards the player OR you can make it move forwards if it has physics on but it won't rotate to face the player. (in fact it just seems to spin like mad)

So we have to do the old CollisionOff/CollisionOn trick around the rotation part.

Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
imothep85
15
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 24th Jul 2021 07:40 Edited at: 24th Jul 2021 07:49
Thanks AmenMoses
it works pretty well but when the object follow the player, he has no weight !!
if i move to a higher platform and leave the platform the object still follow the player, but in the air, like he has no weight & no gravity lol
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/

Attachments

Login to view attachments
imothep85
15
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 25th Jul 2021 14:24
I added this

local maxWeight = 800
GravityOn( e )

but the entity who follow the player only fall if he is on certain distance

local followDist = 200

i need the gravity to be allways on for the entity following the player
so if the entity following me is on a higher platform and he leave that platform he fall
My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/
AmenMoses
GameGuru Master
5
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Jul 2021 19:03
You would have to add some logic to detect when the object is on a platform.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
15
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 25th Jul 2021 23:40
add
MoveUp(e,-100)
after the MoveForward() command
(change the -100 to whatever works)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
imothep85
15
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Belgium
Posted: 26th Jul 2021 07:22 Edited at: 26th Jul 2021 08:00
smallg, it work but the entity following me, fall too slowly !
ALSO when the entity is close to me, the entity fall on the ground like dead, it come from the physics friction, if i put it to zero the entity doesn't fall anymore but when the entity is close to the player it keep turning around the player 360°

thanks to everyone for the help

this is my code:

My Portfolio: https://www.mattepainting.be/
My FREE extension: https://www.stop-it.be/

Attachments

Login to view attachments

Login to post a reply

Server time is: 2021-11-27 11:57:47
Your offset time is: 2021-11-27 11:57:47