Inside3D!
     

func_pushable going in wrong direction
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
catalyst



Joined: 17 Feb 2009
Posts: 26

PostPosted: Thu Feb 19, 2009 10:30 pm    Post subject: func_pushable going in wrong direction Reply with quote

hi,
i'm almost done with my func_pushable code. got a small cube in my map that i can push and it moves... just in the wrong direction. i used the self.enemy.angles attribute to copy the angles to the cube and something is wrong with the angles.
Code:

self.enemy = other;
newdest = self.origin + 4*normalize(self.enemy.angles);

SUB_CalcMove (newdest, 10, pushable_stopped);

any idea, how to make the angles proper?
Back to top
View user's profile Send private message
frag.machine



Joined: 25 Nov 2006
Posts: 728

PostPosted: Fri Feb 20, 2009 1:52 am    Post subject: Reply with quote

Code:

self.enemy = other;
newdest = self.origin + 4*normalize(self.enemy.angles);

newdest = newdest + '0 180 0';

SUB_CalcMove (newdest, 10, pushable_stopped);


Or something like that should do the trick.
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/
Back to top
View user's profile Send private message Visit poster's website
catalyst



Joined: 17 Feb 2009
Posts: 26

PostPosted: Fri Feb 20, 2009 7:59 am    Post subject: Reply with quote

Nope. It just moves the cube 180 units away. I tried adding it to the angle instead
Code:

newdest = self.origin + 4*normalize(self.enemy.angles + '0 180 0');

...but it still moves in wrong direction. Maybe different angles? I'm trying diff combinations like '270 90 0', '90 90 0' with no effect :/
Back to top
View user's profile Send private message
MauveBib



Joined: 04 Nov 2004
Posts: 602

PostPosted: Fri Feb 20, 2009 8:55 am    Post subject: Reply with quote

Try

newdest = self.origin - 4*normalize(self.enemy.angles);
_________________
Apathy Now!
Back to top
View user's profile Send private message
catalyst



Joined: 17 Feb 2009
Posts: 26

PostPosted: Fri Feb 20, 2009 9:07 am    Post subject: Reply with quote

No, I think it has something to do with the point vector vs. angle vector. Cuz newdest is the destination point I pass to the Sub_CalcMove function to move my cube to that point. But, I calculate the destination by adding angles to my origin, instead of adding vectors derived from angles to my origin.

I'm looking for a function that would convert my angles (pitch, yaw, roll), especially yaw, to an XYZ vector to add to the origin.
so...
Code:

//instead of
newdest = self.origin + 4*normalize(self.enemy.angles);

//should probably be something like
newdest = self.origin + dist * AngsToPosition(self.enemy.angles);


I've looked through the Quake-C Built-in functions guide but didnt find anything. Only functions converting position vectors to angles.
Back to top
View user's profile Send private message
catalyst



Joined: 17 Feb 2009
Posts: 26

PostPosted: Fri Feb 20, 2009 9:23 am    Post subject: Reply with quote

hah! i figured it! :D
Code:

dir = normalize(self.enemy.velocity); //gets direction from player's velocity vector (velocity indicates player's direction)
newdest = self.origin + dist *dir; //destination point

SUB_CalcMove (newdest, 10, pushable_stopped);

Just gotta fix the Z direction so the cube doesnt get pushed into the ground when the player jumps on it.
Back to top
View user's profile Send private message
catalyst



Joined: 17 Feb 2009
Posts: 26

PostPosted: Fri Feb 20, 2009 10:02 am    Post subject: Reply with quote

Alright, the next problem...

How do I apply gravity and collision with other objects to the pushable cube? I want it to drop off edges and be carried by elevators etc...

Any simple way to copy the code from another entity?
Back to top
View user's profile Send private message
Spirit



Joined: 20 Nov 2004
Posts: 476

PostPosted: Fri Feb 20, 2009 10:21 am    Post subject: Reply with quote

I think you should take a look at Gyro.
http://quakematt.quakedev.com/gyro.php
_________________
Quake Maps
Back to top
View user's profile Send private message Visit poster's website
catalyst



Joined: 17 Feb 2009
Posts: 26

PostPosted: Fri Feb 20, 2009 1:48 pm    Post subject: Reply with quote

Alright, any idea how to make a simple pushable object in Gyro? :P
...or do I need to register at their forums to ask this question? :D
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Feb 20, 2009 2:22 pm    Post subject: Reply with quote

SUB_CalcMove is a function for items with MOVETYPE_PUSH only.
MOVETYPE_PUSH items are doors/platforms/etc stuff that push other things.
Their movement ignores the world and other MOVETYPE_PUSH objects. This means if you're telling them to move via SUB_CalcMove then they're just going to move through things and never stop on top of them.
Simply put, PUSH cannot touch PUSH.
You would need to use an object which is not MOVETYPE_PUSH (thus not SOLID_BSP either).
What you can do is make it SOLID_BBOX and MOVETYPE_STEP, and call walkmove on it whenever the player bumps into it.
Note that walkmove can recurse, and can result in boxes walking into boxes, but coding that properly is likely to be tricky, so ignore box touching box events.
The walkmove builtin will allow you to push up steps. If you clear the onground flag before calling it, you can push it over edges, and it'll fall down due to gravity (but won't topple over the edge, just suddenly drop when far enough over).
It will sit on moving platforms moving with them, but will not sit on other pushables (so players might get a bump on their head if they try. Because walkmove uses traceboxes, the size of the pushable should be one of the standard hull sizes (you can get away with making it look shorter, but you won't be able to push it through holes that are too small for the hull size).
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Wazat



Joined: 15 Oct 2004
Posts: 732
Location: Middle 'o the desert, USA

PostPosted: Fri Feb 20, 2009 2:25 pm    Post subject: Reply with quote

Never normalize angles, they are distinctly different from directions and velocity.

If you want to turn an angle into a direction, do this:

Code:
makevectors(self.enemy.angles);
newdest = self.origin - 4*v_forward;


makevectors will turn angles into 3 directions: v_forward, v_right, and v_up. When you're working with a player, you can also use makevectors on his .v_angle to tell where he's looking, not just where his model is pointed.

There's a small bug/weirdism where .angles_x and .v_angle_x are reversed, but you don't need to worry about that for what you're doing here.

Another (probably better) option for pushing your box:

Code:

newdir = normalize(self.origin - self.enemy.origin); // direction from them toward me
newdest = self.origin + 4*newdir;


This will always push the box away from the object touching it, no matter what direction they're facing when they bump into it. So if they back into the box it won't respond by going through them; it'll go away from them. This is probably the solution you want.

I hope that helps!
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Back to top
View user's profile Send private message MSN Messenger
Wazat



Joined: 15 Oct 2004
Posts: 732
Location: Middle 'o the desert, USA

PostPosted: Fri Feb 20, 2009 2:32 pm    Post subject: Reply with quote

Ninja'd by Spike. Smile

I also recommend you use MOVETYPE_STEP and SOLID_SLIDEBOX (or BBOX, don't know how important the difference is).

However, you can move such objects by applying velocity and removing the FL_ONGROUND flag each frame. It may work extremely well to do both methods: apply half the movement with the walkmove code, and the other half with velocity. Walkmove doesn't cause walking objects to touch each other (so walking monsters never touch each other, right?), but velocity will, so your boxes can bump into each other with the hybrid system.

I may be able to provide some rough code examples for this later today. In the mean time I need to go to work. Confused

Cheers!
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.
Back to top
View user's profile Send private message MSN Messenger
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Fri Feb 20, 2009 2:51 pm    Post subject: Reply with quote

walkmove triggers triggers. I don't think it triggers solids.
The problem with using velocity to touch other boxes to get them to move is that you're not sure how much it moved beforehand. A tiny tiny velocity is perhaps sufficient in order to get the thing to be touched without being weird.

The problem with most pushables is that pushing against them deflects the player's movement along the plane of the slower-moving pushable. This can be annoying. Make sure the player moves only as much as the thing they are pushing, if they're pushing anything.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
frag.machine



Joined: 25 Nov 2006
Posts: 728

PostPosted: Sat Feb 21, 2009 1:02 am    Post subject: Reply with quote

catalyst wrote:
Nope. It just moves the cube 180 units away. I tried adding it to the angle instead
Code:

newdest = self.origin + 4*normalize(self.enemy.angles + '0 180 0');

...but it still moves in wrong direction. Maybe different angles? I'm trying diff combinations like '270 90 0', '90 90 0' with no effect :/


Ouch, I knew there was something wrong on that. Razz
/me makes note to self: do not try to help in coding when you're too sleepy and/or too drunk. Smile
/me slides slowly and ashamed to the shades
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/
Back to top
View user's profile Send private message Visit poster's website
goldenboy



Joined: 05 Sep 2008
Posts: 310
Location: Kiel

PostPosted: Mon Feb 23, 2009 11:48 pm    Post subject: Reply with quote

Hipnotic and Nehahra have pushables.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group