Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,359 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Moving away from an object independent of axises? #249928
02/04/09 21:25
02/04/09 21:25
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
What I've been trying to figure out through the manual for the past few days in how to make a object move away from another object. I have program a script to move the object through clicking, but what I've been unable to achieve is to move it directly away from the object. IE, if you are standing to the left of an object, it shoots forward from your orientation, not it's own.

Currently, I can make it go forward on the X axis, but If I stand in front of it, it doesn't go backwards, it flies towards me.

Re: Moving away from an object independent of axises? [Re: Tai] #249937
02/04/09 22:53
02/04/09 22:53
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
It is still not clear what you mean.

For instance:

Let the object turn towards another object:

function turn_to_object()
{
vec_set(temp,your.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // now MY looks at YOU
}

Or, let an entity turn away from a certain object:

function turn_away_from_object()
{
vec_set(temp,your.x);
vec_sub(temp,my.x);
vec_inverse(temp);
vec_to_angle(my.pan,temp); // now YOU looks away from MY
}

I don't know whether this snippets give you a hint in the right direction.
At least, it gives you an idea what I didn't understand of your question.

Re: Moving away from an object independent of axises? [Re: Pappenheimer] #249944
02/05/09 00:24
02/05/09 00:24
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
I was thinking more movement then panning. Here's my current code.
Quote:
function steelpush()
{
if(event_type == EVENT_TOUCH)
while(1)
{
while (!mouse_left) wait (1); // wait until the player left clicks
{
if(mouse_left == 1)
{
//phent_addtorqueglobal(me,steelpushvec); // add a torque (an angular force) to the ball
vec_set(steelpushvec,vector(camera.tilt * 10 * camera.pan * -10, camera.tilt * 10 * camera.pan * -10, 0));
phent_addvelcentral(my,steelpushvec);
wait (1);
}
}
}
else

if (event_type == EVENT_RELEASE)
{
{
cant_move();
}
}
}


I've been messing with the values trying to get it to so it moves forward on the axis I'm clicking on, so If I click along the Y axis, it moves forward, but if I click on the X axis it move forward on that.


EDIT:
Well, using that rotate to player is sorta what I wanted, except correlating to movement.

Last edited by Tai; 02/05/09 05:18.
Re: Moving away from an object independent of axises? [Re: Tai] #250024
02/05/09 14:45
02/05/09 14:45
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Quote:
EDIT:
Well, using that rotate to player is sorta what I wanted, except correlating to movement.

Then you only need use c_move with a value for the rel_dist or rel_vel - don't remember the names now.

I didn't know that you use the physics for the movement, that makes it a bit different.
You probably have to add forces parallel to the wanted axis, instead of using c_move - I don't have any experiences with the physics engine.

Looking at your code:
- Why do you make it related to the camera's angle while speaking about x axis and y axis?
- And, you shouldn't put any while instruction into an event, you should use the event only for changing any values, for instance, a flag that activates and de-activates the entity's movement or such.

Re: Moving away from an object independent of axises? [Re: Pappenheimer] #250030
02/05/09 16:10
02/05/09 16:10
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
Your still kinda missing what I mean. I blame myself for not being clear enough though. Here's a image that should illustrate what I mean.

Quote:
- Why do you make it related to the camera's angle while speaking about x axis and y axis?
- And, you shouldn't put any while instruction into an event, you should use the event only for changing any values, for instance, a flag that activates and de-activates the entity's movement or such.


- I was testing to see if using the pan angle of the camera which is the players pan angle would work. It didn't.
- The while event is so when I hold down the click, it continues to move. It doesn't work otherwise.

Last edited by Tai; 02/05/09 16:16.
Re: Moving away from an object independent of axises? [Re: Tai] #250043
02/05/09 17:50
02/05/09 17:50
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Okay, here we go!

You don't want to change the objects angle at all, right?
You simply want to move the object right away from the player's position?

Let's have a look at the example from my post above:

function turn_to_object()
{
vec_set(temp,your.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // now MY looks at YOU
}

The first two lines gives you the direction from me/my to you/your, only the third turns the angle of me/my.
This means after the first two lines 'temp' contains the direction which you can add to the position to the object to move it forward exactly away from the players position - I always have to test such things first, because I often forget the exact way how it works, so please, test on your own!

You can scale the direction with vec_scale(temp, push_strength*time_step) - something like this!

If the use of the vectors are still unclear to you in some respects, you can look for the Kinji's Tutorials, the explain this extraordinary well. I don't know where they are hosted at the moment, though.

Last edited by Pappenheimer; 02/05/09 17:54. Reason: Addirional hint to Kinji's Vector Tutorials
Re: Moving away from an object independent of axises? [Re: Pappenheimer] #250045
02/05/09 17:59
02/05/09 17:59
Joined: Sep 2008
Posts: 68
T
Tai Offline OP
Junior Member
Tai  Offline OP
Junior Member
T

Joined: Sep 2008
Posts: 68
Thanks, I'll give that a try!

It worked!
Quote:
function steelpush()
{
if(event_type == EVENT_TOUCH)
while(1)
{
while (!mouse_left) wait (1); // wait until the player left clicks
{
if(mouse_left == 1)
{
vec_set(temp,player.x);
vec_sub(temp,my.x);
vec_scale(temp);
vec_inverse(temp);
phent_addvelcentral(my,temp);
wait (1);
}
}
}
else

if (event_type == EVENT_RELEASE)
{
{
cant_move();
}
}
}


Last edited by Tai; 02/05/09 18:53. Reason: Results added.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1