HELP? drag and drop?! NEED HELP!

hi i am making a fun little ragdoll game and i really need as an essential part of the mini-game to have the ability to grab any part of my ragdoll and drag him anywhere in the area i have set and then at will ‘drop him’ when the player releases the mouse button.

is there a script to efectively achieve this? or a method using the mouse sensor and a movement actuator? :confused:

Hey Ryley,
I was looking for the same thing a day or two ago,
I searched the forum and found this (it’s not mine),
I guess you can modify it to suit your needs?
put the viewport into shaded mode and hit P to demo it,
right mouse click and hold on the green boxes to drag them, release to let go (or left mouse click to smash off into the distance).
drop the author a thank you if you find it useful, i’m sure they’d appreciate that. :yes:
Hope this helps.
EDIT:
I found the original thread.

http://blenderartists.org/forum/showthread.php?t=146510&highlight=fps_template.blend

thanks a lot for your help! that was very interesting, but i looked at almost all the
scripts logic and found the the ‘dragging’ is spread over many scripts and used with many variables that all link to each other and require many objects to properly run the scripts.

so unfortunately its not quite what im looking for, because im just looking for a simple script
simple to “mouselook” but instead of an object facing the mouse it follows the mouse.
but thanks for your help.

Funny thing about following the mouse in a 3D environment: there are many points that are hit by the mouse at once. In order to do some sort of drag and drop in 3D you’ll probably want to limit the dragging to a 2D plane. For example, fixed Z value.

Then find the point of this plane that the mouse is pointing at, and move the ‘active’ object towards that point.

[EDIT]
I whipped up this blend in a small amount of time… it’s rather buggy, but it might be something like what you want.

To reproduce it:
All draggable objects must have the ‘drag’ property, and all immobile wall objects should have the ‘wall’ property
Other than that, put the same logic/script setup on the camera object, and see how it runs.
It assumes that the hoveroverany sensor is always positive, and may bug if it is not… so roof/wall at all times is probably good.

oh, and you need Blender 2.49 for the script to work.

(If it gives you problems, tell me what the console window says)

Attachments

dragdrop.blend (142 KB)

Thankyou Almost!!! this has helped a lot when the game is finished i might be able to post it here so you can see it! and i will give you heaps of credit thankyou very much!
:smiley:

(BTW i think blender needs to have an actuator called “mouse” and you can set certain traits to make the mouse control an object…maybe for 2.5?)
(sorry if this sounds like i think you are a develeper)

anyway, thanks.

this script is great! but there is one problem, it stuffs up the rigid body constraints i used for my ragdoll. i don’t know what is wrong, i tried finding another method for making ragdolls, but nothing else worked. but like you said; its still a bit glitchy.

oh and whenever i run it with my ragdoll (i have blender 2.49) it says in the console: " File “drag_drop”, line 36 in <module>
AttributeError: ‘module’ object has no attribute ‘hitob’

WHOOPS!!! my fault!!! :rolleyes: :stuck_out_tongue: :no:
i accidentely (i don’t know why) had the ragdoll parts set to ‘compound’ :eek:
by setting the mass, damping and rotation damping to an appropriate level, i fixed the problem.

no more problems…yet

Hey,
This script is exactly what Ive been looking for…Thanks a lot! The thing is Im new to python scripting, so could you please help me explain the code, or give me a link where I could figure out what part of the script does what?

Hey,

Figured out a part of the code. Have 3 questions:

  1. <b>fact = (iz-z1)/dz
     ipoint = [x1 + dx*fact, y1 + dy*fact, z1 + dz*fact]</b>
    

What does this do?

        <b>ray = GameLogic.hitob.rayCast(ipoint,GameLogic.hitob,0,'wall')
        if ray[0] == None:
            x2,y2,z2 = ipoint
        else:
            x2,y2,z2 = ray[1]</b>
  1. what is the parameter syntax for the rayCast method? Couldnt find it anywhere on the GameLogic API.

  2. what does the ray[] array do? Didnt get the ray[0], ray[1] part…

It would be great if you could resolve these doubts.

Thanks

http://www.blender.org/documentation/249PythonDoc/GE/GameTypes.KX_GameObject-class.html#rayCast

Hey, a small doubt…

Almost’s code works with alt+a but I have a few queries:

  1. When I go to text -> Run Python Script it gives me a ‘Python Script Error: Check Console’…Any idea how to fix this?

  2. If I drag the cubes rapidly out of the camera view, they go right out of the container and never come back…Any fixes?"

Thanks

i got some question…

  1. when drag the cube, how to make the other cube do not push away by the selected cube
  2. when release the mouse, how to make the cube stop where i release. (not to slide away when the mouse release)
    ps* i am super newbie. TQ

You shouldn’t revive old threads. If you want help create a new thread in the support section (you’ll get more responses too)