Jump to content

Move to point (not AI)


Andy Gilbert
 Share

Recommended Posts

Hi, im wanting to move an entity to a point but without using navigation or the navmesh, just simply move an entity to a point over time, a bit like the LE2 camera flythough.

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Why not read the docs youGrove?

 

Please dont just assume... I know i can write a function using move,but that command simply moves an object along its own axis. It does not move and object to another point in space.

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

ok i didn't undertsood.

you just need maths :

Calculate the vector than use move function by advancing the model each physic updates.

 

For maths , just try on google search.

 

Or there is some sort of code in the 3rd camera code Chris has done :

The camera is placed behind player in Z position, you could do same by advancing the object along Z local axis.

 

I think it can work like that :

Each physic update :

- turn to object direction you want ot reach

- move with a step number along Z local axis

Stop toying and make games

Link to comment
Share on other sites

iTween for LE3 would be sweet! I haven't even looked at LE3 yet so can't help at this time, but at first glance if you wanted to do this yourself, I would make a separate script that takes an entity as the thing to move, then and entity as the place to move to (pass a pivot as this), and then in the Update() function use the Move() and PointAt() functions to move the object to the destination each frame. Make some kind of enable/disable thing so that you can trigger this process starting. Also check the distance between the 2 points/entities to determine when to stop.

 

This way doesn't use physics though, so not sure if that is a requirement.

 

This would be a great thing for an elevator or something. There are so many little scripts like this that would be so useful and I do mean to make these for people but at this time I have to focus on my game.

Link to comment
Share on other sites

The following is code from my previous LE2 project. The Lua commands are different but the essentials remain.

// Subtract the new position with the models current position
TVec3 moveAmount = NewPosition- modelPosition;

// Normalize it (Math function)
moveAmount.Normalize();

// Calculate speed based on input value and equal frame time
float t =moveSpeed * LE.AppSpeed() * 0.01;
moveAmount = new TVec3(moveAmount.X * t, moveAmount.Y * t, moveAmount.Z * t);

// Check if the distance that has to be moved is larger than a value. if so, move the entity
if (EntityDistance(model, newPosition) > 0.1)
{
MoveEntity(model, moveAmount, 1);
}

  • Upvote 1
Link to comment
Share on other sites

@Rick:

No need for big plugin for such simple stuff.

Simple Lua template will do the job.

 

My question would be more :

How many scripts per scene ? Better to have less scripts and regroup code ? less threads and call i think ?

Depends on your game complexity also.

Stop toying and make games

Link to comment
Share on other sites

iTween does a lot, pretty much everything you need for easing in/out and curving values. A Curve class should be standard as you can use it in everything, movement, color, GUIs, chained animation cycles. And you need variations of it in nearly every project that has to look polished. But I think there's a LUA implementation somewhere. I'll have to rummage.

 

In the meantime Aggror shows the way. If you modify the movespeed based on distance to target you can add accel/decel effects.

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

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...