Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Gradually move player to a position
#1
Question 
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);
}
}
Reply

#2
(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?
Reply

#3
(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
Reply

#4
Use for loop with 'wait 0.1;' or less.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#5
(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
Reply

#6
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?
Reply

#7
(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
Reply

#8
(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
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Spawning player on Snd Cation 4 3,506 07-11-2021, 05:05
Last Post: Scripto
  Help How to force end game for a player? Ra3shed 4 3,639 10-28-2016, 11:52
Last Post: Rendflex
  Change Player Score Xaedrus 8 5,844 04-07-2015, 18:06
Last Post: Nekochan
  Help playing mp player anims zurasaur 5 3,828 09-16-2014, 21:15
Last Post: Yamato
  Changing hitbox's position / model damage? Cation 21 12,814 09-12-2014, 16:24
Last Post: Cation

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.