30-10-2017, 09:32 AM
I want to be able to grab my Rope on the End or Start, and i thought to raycast the end/start of it, so the player can grab it.
How can this be done?
How can this be done?
How to make the Start/End Prefab able to be Raycasted?
|
30-10-2017, 09:32 AM
I want to be able to grab my Rope on the End or Start, and i thought to raycast the end/start of it, so the player can grab it.
How can this be done?
30-10-2017, 11:13 AM
(This post was last modified: 30-10-2017, 11:33 AM by josemendez.)
(30-10-2017, 09:32 AM)Rexima Wrote: I want to be able to grab my Rope on the End or Start, and i thought to raycast the end/start of it, so the player can grab it. Hi there, Raycasting is the wrong approach (in fact, what do you want to raycast exactly? there are no colliders in a rope, and you cannot trivially raycast against a deformable mesh). You should use handles, and a proximity test to see if your grappling point (e.g. player hand) is near the rope end/start. If it is, then create a handle. Alternatively you can just fix the first/last particles in the rope and directly set their position to whatever you need them to be. See: http://obi.virtualmethodstudio.com/tutor...ments.html http://obi.virtualmethodstudio.com/tutor...icles.html Edit: If you're doing this for VR, there are a few threads on the subject: http://obi.virtualmethodstudio.com/forum...ight=niZmo http://obi.virtualmethodstudio.com/forum...ight=niZmo
I have an First Person Character Controller, if i make any proximity checks with the character, than it wont work like expected.
My Player need to aim at one End, the End should be Outlined and than if he press an button, the end is in his "hands". I hope you know what i mean. The player needs to take the rope and connect it with an Entity, so i need to let him grab one End. Edit: I was lil bit stupid... I just attached my Pickup and Outline Script on the Start/End prefabs and now its working. (So now im able to create an handle at the right position) But to grab the Rope i need to create an ObiParticleHandle, right? Is there any good sample / tutorial, how to grab it? I managed to move the handler, but the rope is still on the ground. Do i need to pin the rope end to the handle?
30-10-2017, 04:41 PM
(This post was last modified: 30-10-2017, 04:43 PM by josemendez.)
(30-10-2017, 03:37 PM)Rexima Wrote: I have an First Person Character Controller, if i make any proximity checks with the character, than it wont work like expected. Yes, you need to create a ObiParticleHandle. All of this is in the manual, scripting section. You can either create a handle: Code: // Create the handle: Or use the low-level API to fix the particles in place and move them around yourself. Handles are just a fancy way to move particles around using a transform, but in some cases (like this one) you can just move the particles directly yourself. The sample code in the manual (under "setting particle properties") does exactly this: http://obi.virtualmethodstudio.com/tutor...icles.html
30-10-2017, 09:05 PM
I made what you said and i can hold my rope now, but i when i pick it up, i have only the end and start prefab in my hands.
The rope is away Code: m_handleGO = new GameObject("Obi Handle");
31-10-2017, 02:43 PM
(30-10-2017, 09:05 PM)Rexima Wrote: I made what you said and i can hold my rope now, but i when i pick it up, i have only the end and start prefab in my hands. Hi, FixedUpdate runs once (or zero, or multiple times) per frame, so your code is creating a handle and then adding the same particle to the handle every frame, setting its position to be whatever position the particle has that frame. This is wrong. Particles should only be added once, with the position they should have relative to the handle. The handle will take care of positioning the particle so that it keeps the same position relative to its frame, no need to manually set particle positions if you're using handles.
01-11-2017, 11:23 AM
Thank you very much for your help, but how do i know the new position of each particle?
I need to add all Particles once, and than i need to move the handler where my "hand" is. But the problem is, how to add all Particles, how do i know the new position of them? This is in my Init void: Code: m_handleGO = new GameObject("Obi Handle"); And this in FixedUpdate to move the Handler: Code: m_handleGO.transform.position = Vector3.Lerp(transform.position, PlayerCamera.Instance.transform.position + PlayerCamera.Instance.transform.forward * .8f, Time.deltaTime * 20); In the Attachment you can see, how it looks, when i pick the rope up.
01-11-2017, 02:06 PM
(This post was last modified: 01-11-2017, 02:09 PM by josemendez.)
(01-11-2017, 11:23 AM)Rexima Wrote: Thank you very much for your help, but how do i know the new position of each particle? Hi! Why do you divide the position of each particle by its mass when initializing the handle? It doesn't make sense in this context... and will yield completely incorrect results for your purposes. Also, you're adding ALL particles in the rope to the handle. I was under the impression that you only wanted the first/last particles to be handled, and let the rest of the rope be simulated. The initial position of each particle in the handle must be the one you wish them to be in relation to the handle. For instance, if you wish the particle to be exactly on top of the handle, then you must pass the handle's position. Passing the current particle position as you do now, will NOT make the particle "teleport" to the handle position at the start, it will make sure the particle keeps that position relative to the handle. From then on, the handle itself will make sure that the particles keep the same position in its local space. You no longer need to do anything once the handle has been set up. Just moving the handle around will be enough.
Sorry for real, i try to understand how it works. Thank you very much, you are so patient.
I will try to explain how my concept is now made. The Start and End Prefab have 2 scripts attached. One for Outlining and one which handles, what should happen, when my player is hitting it. The two Prefabs have an Collider attached and are on the Layer "Pickable" So, when my player aim at the start or end object, the object get outlined and i can press an button to interact with this object. When i press an button, it will call an function on the object. This works so far, i can interact with the created end / start prefab. So, the script on the prefabs, looks like this: https://hastebin.com/gohosewoyi.cs With this code, im moving the handle but not the rope end. Edit: I just added this line "m_handle.AddParticle(0, transform.position, 1f);" (https://hastebin.com/ebevojocak.cs) and now i grab the first particle, i think. I need to figure out, how to grab the right particle, than its working Edit 2: Ok, i think its working like i said now. Thank you very much.
01-11-2017, 08:19 PM
(This post was last modified: 01-11-2017, 08:19 PM by josemendez.)
Glad you got it working! If you need further help don't hesitate to ask.
|
« Next Oldest | Next Newest »
|