Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / throw object script problem

Author
Message
SAAB Driver
19
Years of Service
User Offline
Joined: 1st Nov 2005
Location:
Posted: 13th Aug 2009 11:51 Edited at: 13th Aug 2009 11:56
Hi guys, im tryin to find a way to make the player able to throw an object, in this code its a handgrande.


what is happening here is that when the throwbotton is pressed the "greandeobject" (object 3) is get velocity x -30, unfortuanatly it doesnt get that velocity value out of the players direction. So if the player rotate to another direction and throw the greande, the grenade will move in the (of the game)main x direction.

If player is in direction X and rotate to direction Z the grenade (velocity) value wont rotate with the player, so the grenade will always move in the same direction.

So what i need is a way top make the grenade constantly move in the x direction (forward from the player) of the player.

Have nice day!

Hello!
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 13th Aug 2009 12:07 Edited at: 13th Aug 2009 12:14
This is from one of the Physx demo sources.
I use it for thrown objects, haven't found a simpler way to work out the angles, works good.

Just work out the X angle (elevation) and the players facing Y angle. Think you mixed up the angles with the positions as describing the X angle for the facing.



Regards
SAAB Driver
19
Years of Service
User Offline
Joined: 1st Nov 2005
Location:
Posted: 13th Aug 2009 22:01
Great but it doesnt really work as i tought.
The first problem comes when i erase this part

and write your code instead. Once i try to run the script i wont start and i get an error message that object already exist at lin 469, witch it doesnt do cause that a completly diffrent object. This has actually happend at erliers stages when i took the same part of the code away from the "throw object script".

To make it run i have to write this


Once i click the throwbutton the grenade appears on top of the player, it seems that there is no velocity that drag the greande away from the player, is there a way to adjust it? or am i doing something wrong?

Thank you for taking time Duke E!

Hello!
sindore
20
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 14th Aug 2009 05:48
you could always try adding the y angle to the -30, for example -30+payer_angle_y#

payer_angle_y# = object angle y(player)

phy set rigid body linear velocity 3,-30+payer_angle_y#,(i)-30,0

this is just a shot in the dark, I haven't tested it

soul sucking devils, twisted body of the damed, slivering slim drips from every poor, sin licking at your ears, and the smell stinging your eyes, and if you don't like it, get out of my kitchen!
sindore
20
Years of Service
User Offline
Joined: 2nd Jul 2004
Location: Bedfordshire, UK
Posted: 14th Aug 2009 05:58
its a bit old so this looks a bit messed up be cos of updates to dp, but this may help you

Spinning Top


I used
to fire my spinning tops.

hope this helps

soul sucking devils, twisted body of the damed, slivering slim drips from every poor, sin licking at your ears, and the smell stinging your eyes, and if you don't like it, get out of my kitchen!

Login to post a reply

Server time is: 2024-11-24 16:32:56
Your offset time is: 2024-11-24 16:32:56