ItsMods

Full Version: Gradually move player to a position
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I'm relatively new to scripting.

I want to be able to move from a spot where I'm standing, to another position.

This code works, however i need it so i gradually move positions instead of instantly teleporting.

could any ones brilliant scripting knowledge tell me how i could do this please. Im sorry if this was a noob question Big Grin


I've got this code in my gsc at the moment

Code:
savePos()
{
self endon("disconnect");
self notifyOnPlayerCommand("save", "save");
for ( ;; )
{
self waittill("save");
self.saved_origin = self.origin;
self.saved_angles = self.angles;
}
}

loadPos()
{
self endon("disconnect");
self notifyOnPlayerCommand("load", "load");

for ( ;; )
{
self waittill("load");
self freezecontrols(true);
wait 0.05;
self setPlayerAngles(self.saved_angles);
self setOrigin(self.saved_origin);
self freezecontrols(false);
}
}
(07-03-2014, 19:31)zurasaur Wrote: [ -> ]Hi, I'm relatively new to scripting.

I want to be able to move from a spot where I'm standing, to another position.

This code works, however i need it so i gradually move positions instead of instantly teleporting.

could any ones brilliant scripting knowledge tell me how i could do this please. Im sorry if this was a noob question Big Grin


I've got this code in my gsc at the moment


Use Insert formatted code or Insert formatted PHP code if you paste any code.

So you want to automatically go to Y position from X? Like a BOT?
(07-03-2014, 19:58)RaZ Wrote: [ -> ]
(07-03-2014, 19:31)zurasaur Wrote: [ -> ]Hi, I'm relatively new to scripting.

I want to be able to move from a spot where I'm standing, to another position.

This code works, however i need it so i gradually move positions instead of instantly teleporting.

could any ones brilliant scripting knowledge tell me how i could do this please. Im sorry if this was a noob question Big Grin


I've got this code in my gsc at the moment


Use Insert formatted code or Insert formatted PHP code if you paste any code.

So you want to automatically go to Y position from X? Like a BOT?

yes exactly, just not instantly. i want the player to move gradually.

sorry for not formatting correctly
Use for loop with 'wait 0.1;' or less.
(07-03-2014, 20:17)SailorMoon Wrote: [ -> ]Use for loop with 'wait 0.1;' or less.

i have read a loops tutorial by yamato, and i understand loops. but im not sure i understand what exactly i should loop Confused, could you explain or give me a pointer pretty please? Blush
i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:

I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @Yamato has a tutorial for moving objects.

Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?
(07-03-2014, 21:14)Rendflex Wrote: [ -> ]i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:

I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @Yamato has a tutorial for moving objects.

Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?

Really helps, ill give it a try now Big Grin
(07-03-2014, 21:14)Rendflex Wrote: [ -> ]i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:

I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @Yamato has a tutorial for moving objects.

Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?

completely solved my initial issue, thanks a lot man.

only issue I'm having now is not being able to unlink the object. not sure on the function to do it.

(07-03-2014, 23:34)zurasaur Wrote: [ -> ]
(07-03-2014, 21:14)Rendflex Wrote: [ -> ]i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:

I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @Yamato has a tutorial for moving objects.

Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?

completely solved my initial issue, thanks a lot man.

only issue I'm having now is not being able to unlink the object. not sure on the function to do it.

/solved

thanks to everyone who helped