1 registered members (Akow),
1,359
guests, and 11
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Senior Expert
|
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
Tai
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2008
Posts: 68
|
I was thinking more movement then panning. Here's my current code. 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
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
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
Tai
OP
Junior Member
|
OP
Junior Member
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. - 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
Senior Expert
|
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
Tai
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2008
Posts: 68
|
Thanks, I'll give that a try! It worked! 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.
|
|
|
|