About Store Forum Documentation Contact



Post Reply 
Physic Movement.
Author Message
Salival Offline
Member

Post: #1
Physic Movement.
Hello.

I was going to try writing an own character movement. I do not want to use the existing because it rotating before move and I want instant movement and rotate at same time.

My math is a bit rusty atm, maybe someone can help out or if esenthel can tell how you made your movement code.

So here I begin but it does not move in same speed in all directions, also sometimes stuck in the terrain.

Code:
// Move to target position.
Vec dir = (TargetPos - pos());
dir.normalize();

ctrl.update(dir, 0, 0); // <- Error here, Only works when jump = 1. (Wierd)

Thanks.
(This post was last modified: 06-03-2011 10:21 AM by Salival.)
05-31-2011 03:47 PM
Find all posts by this user Quote this message in a reply
menajev Offline
Member

Post: #2
RE: Physic Movement.
actor.vel
(This post was last modified: 05-31-2011 06:01 PM by menajev.)
05-31-2011 06:01 PM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #3
RE: Physic Movement.
What do you mean?
05-31-2011 08:52 PM
Find all posts by this user Quote this message in a reply
menajev Offline
Member

Post: #4
RE: Physic Movement.
I mean adding force is very inaccuracy and quite random (and it's affected by fps somehow). You should use actor.vel to create regular movement.
05-31-2011 09:22 PM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #5
RE: Physic Movement.
Okay, Well still the problem that I get stuck in terrain.

Esenthel, How is your movement func made?
(This post was last modified: 06-01-2011 07:31 AM by Salival.)
06-01-2011 07:15 AM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #6
RE: Physic Movement.
Using ctrl.update(vel... seems to not stuck in terrain, but the problem with update is that it works only when you jump? Why is it like that?

With this code nothing happens.
Code:
Vec dir = (TargetPos - pos());
dir.normalize();
ctrl.update(dir, 0, 0);

But change to ctrl.update(dir, 0, 1) it moves just fine but jumps all the time :]
(This post was last modified: 06-01-2011 08:49 AM by Salival.)
06-01-2011 08:48 AM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #7
RE: Physic Movement.
So, Esenthel, Why does ctrl.update(dir, 0, 0) not apply any velocity? But if Jump param is 1, it apply everytime it jumps.

Wierd, Anyone else got same problem?
Or is it possible to turn off the object rotation at Chr::actionMoveTo func?

Current: actionMoveTo -> Turn object to face target -> Move.
Wanted: actionMoveTo -> Move & Turn object at same time or only move.

That's why I want to create my own movement function if this is not possible with your actionMoveTo func.
(This post was last modified: 06-01-2011 12:17 PM by Salival.)
06-01-2011 11:40 AM
Find all posts by this user Quote this message in a reply
menajev Offline
Member

Post: #8
RE: Physic Movement.
You want character to go forward while rotating (so move in current direction) or move in destination direction apart from he's currently angle?
06-01-2011 01:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #9
RE: Physic Movement.
ctrl.update works by setting actor.vel
what do you mean player gets stuck? attach an image.
ctrl.update will not apply velocity if the ground is to steep (not flat), in that case ctrl.onGround will return false
06-01-2011 02:38 PM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #10
RE: Physic Movement.
(06-01-2011 02:38 PM)Esenthel Wrote:  ctrl.update works by setting actor.vel
what do you mean player gets stuck? attach an image.
ctrl.update will not apply velocity if the ground is to steep (not flat), in that case ctrl.onGround will return false

I use ctrl.update and it does not apply any velocity (Only if I jump) and my character stands on flat ground.

Maybe some bug?

actor.vel if I set this, the character stuck in the ground, Like it does not "move" ontop of collision or something like that.
(This post was last modified: 06-01-2011 03:04 PM by Salival.)
06-01-2011 03:03 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #11
RE: Physic Movement.
there is tutorial with Controller, and last time I checked it, it worked fine
06-01-2011 06:06 PM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #12
RE: Physic Movement.
(06-01-2011 06:06 PM)Esenthel Wrote:  there is tutorial with Controller, and last time I checked it, it worked fine

I know there is a tutorial with Controller. It works for me when I move on static objects, but on terrain it does not work.
06-01-2011 06:53 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #13
RE: Physic Movement.
and tutorial "11 - Physical meshes" ?
06-01-2011 06:56 PM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #14
RE: Physic Movement.
ctrl.update used in the same way in this tutorial, So I do not see the problem. Also wierd thing is that ctrl.update apply velocity only when I jump.
06-01-2011 07:11 PM
Find all posts by this user Quote this message in a reply
Salival Offline
Member

Post: #15
RE: Physic Movement.
Esenthel:

Can you add an option for the movement function ( actionMoveTo ) if you want to have rotation or not. If rotating is OFF it starts to move towards the target directly and does not wait to rotate.

1# Must rotate before moving. (Like now)
2# Rotate and move at same time. (Wanted) <- Please add.

PS:

I did some tests with the tutorial (11), when adding static mesh (like wall as ground) then it ctrl.update(vel..) works without problems. But when you load a terrain and place the player on it does not work, only if you jump, Wierd... But it works if I set Physics.gravity(Vec(0,0.1,0)), But I do not want flying character :] So something is messy when the character is touching the terrain. (NO I do not stand in a slope, flat ground)

Please check this.
(This post was last modified: 06-03-2011 10:23 AM by Salival.)
06-03-2011 09:33 AM
Find all posts by this user Quote this message in a reply
Post Reply