Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-26-2012, 04:39 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Smooth movement takes a while to finish

I don't really know where to go with this one O.O I'm attempting to smoothly move the player from one point to another. I've got the smooth movement working, but as the player is slowing down (closing in to the final destination), the movement slows and it takes a good 5 seconds to finish the movement even though nothing nothing visibly happening.



Here's the code:

PHP Code:
function onMouseWheel() {
  
temp.dest = {mousexmousey};
  
temp.angle getangle((player.temp.dest[0]), (player.temp.dest[1]));
  
temp.odist vectordist({player.xplayer.yplayer.z}, {dest[0], dest[1], player.z});
  
  while(
player.!= temp.dest[0] && player.1!= temp.dest[1]) {
    
temp.distance vectordist({player.xplayer.yplayer.z}, {dest[0], dest[1], player.z});
    
player.-= cos(angle) * (distance odist);
    
player.+= sin(angle) * (distance odist);
    
player.chat "Moving... (Distance:" SPC distance ")";
    
sleep(0.05);
  }
  
  
player.chat "Finished movement";

I tried to solve it by doing something like:
PHP Code:
if (distance <= 0.1) {
  
player.dest[0];
  
player.dest[1];

But that resulted it a jolty finish, which isn't what I want.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.