how do you use the mouse to pick up an object and throw it like the force unleashed?
This forum is now archived!
- Welcome to the archive!
News:
The 3DRad community can be found at classdev.net.
- 3D Rad - Free 3D game maker - Forum >
- General Category >
- 3D Rad - Technical Discussion >
- how do you use the mouse to pick up an object
Author Topic: how do you use the mouse to pick up an object (Read 3009 times)
jestermon
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
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
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.
you know the way it works in the force unleashed game.
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
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().
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().
That's awesome! 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
I will definitely make a demo of the force!
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
I will definitely make a demo of the force!
jestermon
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. . . . . . .
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. . . . . . .
now nothing can stop the empire my lord!
good the force is with us, all thinks to jestermon and jester-3po
Thanks jestermon that's awsome, how do you script so fast?
good the force is with us, all thinks to jestermon and jester-3po
Thanks jestermon that's awsome, how do you script so fast?
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?
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
but did you know the communicator in the scene about midi-clorine is a razor?
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
for some reason if you right click on 3drad randomly it just crashes, unless I hold the object and right click to throw. not sure why.
jestermon
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
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.
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.
Pages: [1] 2