Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Walk speed acceleration/deceleration.  (Read 2914 times)

0 Members and 1 Guest are viewing this topic.

Akatosh

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 14
  • Discomfort generates evolution.
    • View Profile
Walk speed acceleration/deceleration.
« on: May 29, 2010, 03:43:36 AM »

Good evening,

I would like to know if it's possible to dynamically change a character's velocity, while he moves. The character would react like a car, with an acceleration and deceleration.

I tried overwriting the GoTo and GoToAsync method and implementing a mathamic formula, but with no success.

Code: [Select]
method GoTo (X,Y)
{
  var d = Math.Sqrt(Math.Abs(Math.Pow((X-this.X),2))-Math.Abs(Math.Pow((Y-this.Y),2)));
  this.GoToAsync(X,Y)
  for (var i=0; i<=d; i=i+1) {
     this.velocity = (270-270*Math.Exp(-i/2))-(270*Math.Exp((i-d)/2));
     Sleep(d/270);
  }
}


I even tried putting the GoTo/GoToAsync inside the cycle, but what I found out was that when you send the character to a X and Y, the character will move with his initial velocity until he gets to those points.

I don't want to use the DirectWalk because I want the characters to do bends.

Am I doing something wrong or since the char's velocity is constant it's impossible to add acceleration and deceleration ?
 

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Walk speed acceleration/deceleration.
« Reply #1 on: May 29, 2010, 07:14:30 AM »

WME scripts are case-sensitive, to it should be this.Velocity.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Akatosh

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 14
  • Discomfort generates evolution.
    • View Profile
Re: Walk speed acceleration/deceleration.
« Reply #2 on: May 29, 2010, 10:34:58 AM »

I don't even know why I didn't see that.

Thank you for the tip and the quick reply :)
 

Page created in 0.042 seconds with 23 queries.