Jump to content

Moving An Entity Smoothly Between Two Points


Shard
 Share

Recommended Posts

Hey guys, got another question. (Sorry about that btw, working on a tight deadline and having a few last minute troubles)

 

I need to move an Entity smoothly between multiple TVec3's that I have and I'm not having any luck doing it right.

Essentially it is a Way point navigation but the only problem that I'm having is getting a Entity to move between two points at a time.

 

Currently I've had to resort to jumps between the locations but I would really like it to be smoothed out.

 

Any code samples would be greatly appreciated.

 

Current Code

if(KeyHit(KEY_SPACE))

{

 

wayPoints[current+1].Y = currentPos.Y;

PositionEntity( enemyController, wayPoints[current+1]);

}

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Use PointEntity() and MoveEntity(). Your PositionEntity() just places it there, without moving it.

You might need to use eventually physics commands though, unless the entity you are moving is not supposed to collide with anything.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Use PointEntity() and MoveEntity(). Your PositionEntity() just places it there, without moving it.

You might need to use eventually physics commands though, unless the entity you are moving is not supposed to collide with anything.

 

 

I have already tried doing that but point entity takes an entity as a second parameter, which I don't have. I only have TVec3.

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Then you need to create a Pivot and use PositionEntity() to place it to the Vec3 location.

You can delete the pivot when a new waypoint is selected, or just keep them until the game ends.

It would probably make more sense to use Pivots as waypoints instead of Vec3s, then you need also less coding and your program runs faster.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

The easiest way to do this is to use a Lerp function on the entity position and just call PositionEntity.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...