Latest Threads |
NullReferenceException Bl...
Forum: Obi Cloth
Last Post: dramatemple
24-04-2024, 04:23 PM
» Replies: 8
» Views: 2,401
|
IdentifyMovingColliders.E...
Forum: Obi Rope
Last Post: Guillaume
24-04-2024, 08:57 AM
» Replies: 6
» Views: 60
|
Getting the force acting ...
Forum: Obi Rope
Last Post: josemendez
24-04-2024, 08:40 AM
» Replies: 4
» Views: 61
|
Obi Rope snake "collision...
Forum: Obi Rope
Last Post: josemendez
24-04-2024, 07:32 AM
» Replies: 1
» Views: 37
|
Question about garment on...
Forum: Obi Cloth
Last Post: onfitpark
24-04-2024, 04:45 AM
» Replies: 7
» Views: 213
|
(7.0) New particle shader...
Forum: General
Last Post: kodra
22-04-2024, 07:18 PM
» Replies: 0
» Views: 42
|
Cloth abnormally twists i...
Forum: Obi Cloth
Last Post: josemendez
22-04-2024, 09:06 AM
» Replies: 5
» Views: 2,533
|
(7.0) Compute backend see...
Forum: General
Last Post: kodra
21-04-2024, 01:14 PM
» Replies: 7
» Views: 341
|
Problem with softbody and...
Forum: Obi Softbody
Last Post: josemendez
18-04-2024, 01:12 PM
» Replies: 5
» Views: 139
|
Exclude some particles fr...
Forum: Obi Fluid
Last Post: josemendez
17-04-2024, 11:54 AM
» Replies: 1
» Views: 73
|
|
|
ObiRopeCursor.ChangeLength causes IndexOutOfRangeExceptions |
Posted by: protomenace - 20-06-2020, 05:31 PM - Forum: Obi Rope
- Replies (1)
|
|
I'm trying to create a harpoon gun which is launched from a flying drone and hooks into whatever it collides with. The rope blueprint looks like this:
To shoot the harpoon, I'm starting with a very short rope, and increasing the length of the rope along with the velocity of the tip of my harpoon in FixedUpdate. The rope is attached to both the drone and the harpoon tip via ObiParticleAttachment.
Code: using Obi;
using UnityEngine;
public class HarpoonLauncher : MonoBehaviour
{
public ObiRopeCursor ropeCursor;
public float HarpoonVelocity = 10f;
public HarpoonTip HarpoonTip;
public Transform HarpoonConnection;
public Transform TipSpawnPosition;
public ObiSolver ObiSolver;
public ObiRope Rope;
public float InitialRopeLength = 1f;
public float MaxRopeLength = 5f;
public ObiParticleAttachment TipAttachment, DroneAttachment;
public ObiRopeBlueprint RopeBlueprint;
bool isShooting = false;
// Start is called before the first frame update
void Start() {
InitialRopeLength = Rope.restLength;
HarpoonTip.OnHarpoonEnter += WhenHarpoonImpacts;
}
private void OnDestroy() {
HarpoonTip.OnHarpoonEnter -= WhenHarpoonImpacts;
}
private void WhenHarpoonImpacts(HarpoonTip source, Collider impact) {
isShooting = false;
// Readjust length after impact
ropeCursor.ChangeLength((TipSpawnPosition.position - HarpoonTip.transform.position).magnitude + .02f);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) {
ObiSolver.gameObject.SetActive(true);
HarpoonTip.gameObject.SetActive(true);
ropeCursor.ChangeLength(InitialRopeLength);
HarpoonTip.transform.position = TipSpawnPosition.position;
Vector3 velo = TipSpawnPosition.forward * HarpoonVelocity;
HarpoonTip.Fire(velo);
//Rope.SetMass(.01f);
isShooting = true;
}
}
private void FixedUpdate() {
if (isShooting) {
Debug.Log($"{Rope.restLength}");
if (Rope.restLength >= MaxRopeLength) {
isShooting = false;
}
else {
//Rope.SetMass(.01f);
ropeCursor.ChangeLength(Rope.restLength + HarpoonTip.GetComponent<Rigidbody>().velocity.magnitude * Time.fixedDeltaTime);
//CurrentRopeLength += HarpoonTip.velocity.magnitude;
}
}
}
}
When I run this code, i get an IndexOutOfRangeExceptions in FixedUpdate after shooting the harpoon:
Quote:IndexOutOfRangeException: Index was outside the bounds of the array.
Obi.ObiActor.SwapWithFirstInactiveParticle (System.Int32 actorIndex) (at Assets/Obi/Scripts/Common/Actors/ObiActor.cs:420)
Obi.ObiActor.ActivateParticle (System.Int32 actorIndex) (at Assets/Obi/Scripts/Common/Actors/ObiActor.cs:434)
Obi.ObiRopeCursor.AddParticleAt (System.Int32 index) (at Assets/Obi/Scripts/RopeAndRod/Actors/ObiRopeCursor.cs:118)
Obi.ObiRopeCursor.ChangeLength (System.Single newLength) (at Assets/Obi/Scripts/RopeAndRod/Actors/ObiRopeCursor.cs:203)
HarpoonLauncher.FixedUpdate () (at Assets/Scripts/HarpoonLauncher.cs:60)
However the rope length still seems to change! So what am I doing wrong here?
|
|
|
Access ObiEmitter class in C# |
Posted by: fluidman84 - 20-06-2020, 04:19 AM - Forum: Obi Fluid
- Replies (2)
|
|
I'm sure that there is a easy answer to this, but I've looked all over for the correct namespace to gain access to the speed property on a ObiEmitter component. In the docs I only see Obi.ObiActor referenced, but my IDE only identifies Obi.ObiCharacter.
What am I missing to get access to ObiEmitter?
|
|
|
Particle size over lifetime |
Posted by: Barbelot - 18-06-2020, 10:59 AM - Forum: Obi Fluid
- Replies (2)
|
|
Hello,
I am trying to create a constant stream with Obi Fluid with a source that emit constantly.
However I run into an issue where the particle removed as they reach their lifetime limit create visible blinking as they disappear instantly.
Here is a gif of the issue : https://imgur.com/Pzgkvnh
Is there a way to make the particles fade out in size or color as they reach their death ? Like a size over lifetime or color over lifetime parameter ?
Have a nice day !
|
|
|
Solver.OnParticleCollision not work + mix 3 color |
Posted by: hungseparate - 18-06-2020, 04:05 AM - Forum: Obi Fluid
- Replies (4)
|
|
Hi, im working on a project that currently using obi fluid 5.3
1. As i follow tutorial with collision callback, i noticed that solver.OnParticleCollision not work as i expect.
- ObiSolver.ObiCollisionEventArgs alway return with count = 0.
- I already change emitter A and B with difference phase (1 & 2) still not work
2.Im checking your mixing color scene, i saw that it use field "x" in diffusion data, it running from 0 - 1 and revert.
- Is this value update auto by obi ?
- I want to mix 3 or more color, how can i use this data to receive infomation i need ?
Thanks !
|
|
|
Add cloth and runtime |
Posted by: renderlux - 17-06-2020, 03:54 PM - Forum: Obi Cloth
- Replies (5)
|
|
I'm trying to add ObiSkinnedCloth and reference skinnedClothBlueprint
var gameObj = meshObject.AddComponent<ObiSkinnedCloth>();
gameObj.skinnedClothBlueprint = ScriptableObject.Instantiate(SourceBlueprint.instance.sourceTop);
meshObject.AddComponent<ObiSkinnedClothRenderer>();
But I'm getting
NullReferenceException: Object reference not set to an instance of an object
I believe the problem is:
gameObj.skinnedClothBlueprint = ScriptableObject.Instantiate(SourceBlueprint.instance.sourceTop);
|
|
|
|