3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2

Author Topic: how do you use the mouse to pick up an object  (Read 3009 times)

« on: December 11, 2011, 06:40:25 PM »
how do you use the mouse to pick up an object and throw it like the force unleashed? :)

jestermon

« Reply #1 on: December 11, 2011, 08:11:16 PM »
There are many ways to do it.

Basically you need to either pick or scan an object - usually a rigidbody, and save the object info. You can optionally move the picked object around if you wish, or just leave it in place. The next step is to select a target, whether it is via a scanner or just a direction vector.

This can be easy or complex.
Easy - pick a point to throw towards.
Complex - calculate a direction and force Vector based on direction and speed of the mouse, as well as the angle of release.

Once this is in place, you need to apply a force or velocity to the object to move it.

Allen has done some great work in this area, but I guess that's it's a bit complex for a game, unless you really want some great realism.

Here's a very simple solution, which may, or may not be what you need.
A First Person cam lets you walk around with a long nose. The nose is the scanner to help see what can be picked.

Left click on any rigidbody object to "pick" it, except the ground (You can't really throw the ground). The object is not picked up, since the "Force" was used to move something from place to place, not to juggle stuff with. You can throw anything in the scene, at anything else.

Right click an any rigidbody in the scene, including the ground. The point the scanner touches, becomes a pin-point target - Then watch the "force" in action, as it blasts everything in its path.
The velocity vector is from the center of the selected object to the pin point selection of the target.

Press ENTER to reset, and play "Yoda" all over again.

If you want the selected object to be "picked up", get the length of the scan IN_xx and use that to place the object "to screen view", as one would do with a gun.

V7.02
Have fun
« Last Edit: December 11, 2011, 08:17:03 PM by jestermon »
« Reply #2 on: December 11, 2011, 08:43:55 PM »
that's awesome! can I select the object and move it around before I throw it?
you know the way it works in the force unleashed game. :)

jestermon

« Reply #3 on: December 11, 2011, 08:47:02 PM »
I have not played the game yet. Explain how it's done in the game - effects and controls.
« Reply #4 on: December 12, 2011, 09:53:26 AM »
OMG THIS IS AWESOME! i can even make some kind of mysterius tetris than ;)
::=::Look at this ::=::
Rally game

The most important thing that happens, you usualy miss it , but after sometime you will remember
 
even if you didint noticed. Go forward and never look back
« Reply #5 on: December 12, 2011, 02:55:22 PM »
I have not played the game yet. Explain how it's done in the game - effects and controls.
This video explains it well http://www.youtube.com/watch?v=1Wz7qgoTbtQ  :)

jestermon

« Reply #6 on: December 12, 2011, 07:50:28 PM »
Interesting video. Thanks for the info.
I had two options to make this happen.
1.. to use buttons to move the picked object towards and away from the player, and another set of buttons to move the object horizontal to the view of the camera.
2.. to use buttons to move the picked object towards and away from the camera, and keep the distance fixed, when rotating the camera. This way as you turn, the object rotates with the view.

I opted for the second option, since it's less buttons to press, and pretty easy to control. (I was really just too lazy to do the maths for the second option).

Controls
Keep left mouse button in on scanned object, and as you look around, it will follow the scanner, as though it's stuck like a marshmallow on a stick.
Release the left mouse button to drop the object- No velocity applied to throw the object, since that ideas was not used in the demo video, Shout, and I'll add it if you need.
PgUP to move a picked up object further away
PgDn to move a picked up object closer.

Slam the picked up RB into other RB's with a turn of the camera, or while moving the object closer or further.

Link as shown in the demo, and also set all targets in the scanner as well.
You can change the movement (towards-away) speed in the script.

"Luke.. May the Rad-Force be with you"
7.03

Note: iObjectLocationSet() may not work on all RB's, in that case, replace it with iOBjectLocationReset().
« Last Edit: December 12, 2011, 07:59:45 PM by jestermon »
« Reply #7 on: December 12, 2011, 08:42:34 PM »
That's awesome!  ;D the last thing I might need it the force push blast.
as in I need to be able to throw an object while I hold it and aim it while holding it. :)
If you have time of course  :D
I will definitely make a demo of the force!

jestermon

« Reply #8 on: December 12, 2011, 09:52:30 PM »
Ok, done. I did say you must shout.

Controls.
Mouse move to look around
Left Click mouse button: Keep in - to pick up object
PgUp to move object further
PgDn to move object closer
Right Click mouse button to push any object. Even if not picked up
If the object is picked up, Aim it, and then Click Right mouse button - and at same time - Release Left mouse button.
The force of the "push" can be changed in the script.
ENTER to reset objects

V7.03
Luke... *cough* *cough*...*wheez*.... I am ... *cough*..... I am.... *cough*... This smoking will kill me.. *wheez*... I am your. . . . . . .
« Reply #9 on: December 13, 2011, 03:25:31 PM »
now nothing can stop the empire my lord! :-X
good the force is with us, all thinks to jestermon and jester-3po  :D :D

Thanks jestermon that's awsome, how do you script so fast? :)

jestermon

« Reply #10 on: December 13, 2011, 05:26:54 PM »
... how do you script so fast? :)
It must be due to my high "metachlorine" count :P
« Reply #11 on: December 13, 2011, 08:46:30 PM »
Wow, took me a while to figure out "metachlorine", you know more about star wars terms than I do! ;)
but did you know the communicator in the scene about midi-clorine is a razor? :D
or that the blaster is a hair dryer?
http://4.bp.blogspot.com/Tq_xtgzPCM/Tgvk8FEW2cI/AAAAAAAAEhQ/trPAuNoHacQ/s1600/square%2Bhair%2Bdryer.jpg
this type of one :)
« Reply #12 on: December 13, 2011, 09:21:45 PM »
for some reason if you right click on 3drad randomly it just crashes, unless I hold the object and right click to throw. :o not sure why.

jestermon

« Reply #13 on: December 13, 2011, 10:15:09 PM »
Yes, I picked up the bug. It's the physics thing. We are not really supposed to use "Reset" calls, since it upsets the physics engine. If you turn off gravity then the problem goes away - But that's not of much use. I'll have to see what workaround there is, if any.

jestermon

« Reply #14 on: December 13, 2011, 11:39:46 PM »
Ah.. Found it.

Small change.
Left mouse button DOWN to pick up object
Left mouse button UP to release and throw object
To "push" stuff, do a quick left click and release. It actually picks the stuff up and throws it.
The rest of the controls are the same.

Edit:

I spoke too soon. Silly me. It seems that when you pick up an object and drag it halfway through the ground, and then release it, it makes the physics engine go into a spasm, and crashes the system.

So the bottom line is, that the only way to do things safely, is by using Allan's method of applying forces.

V7.11 upwards has the feature to apply force to a RB from script with iObjectForceApply().
I only use 6.50/7.03 and 7.22. If you have 7.22 then I could make something that could be a lot of fun.

I also saw the makings of a great billiards/snooker game, while throwing rocks at each other.
« Last Edit: December 14, 2011, 12:14:13 AM by jestermon »
Pages: [1] 2