nnpa
March 9, 2023, 8:57am
1
i add ghost control for player
GhostControl gc = new GhostControl(sphereShape);
gc.addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
playerVisual.spatial.addControl(gc);
physics.getPhysicsSpace().add(gc);
and add ghost control for monster
GhostControl gc = new GhostControl(sphereShape);
gc.addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
model.addControl(gc);
physics.getPhysicsSpace().add(gc);
but they don’t collide
How do you know they dont collide properly for a GhostControl?
2 Likes
nnpa
March 9, 2023, 9:27am
3
i dont konow
it is possible that a collision occurs and it can be fixed
but I need them not to pass through each other
nnpa:
i dont konow
then why write “but they don’t collide” ?
did you read the Wiki about them?
1 Like
nnpa
March 9, 2023, 9:31am
5
I read the forum and there they advised to make ghost control for a collision of two characters
why not read the Wiki then?
It will provide you information what is GhostControl really.
nnpa
March 9, 2023, 9:39am
8
read
but my code does not differ from the example
then you didnt read with understanding.
Your answer is in Wiki, in like less than 1 minute of reading. in 6-10 first lines of text.
i will even copy paste Wiki here:
Attach a com.jme3.bullet.control.GhostControl to any Spatial to turn it into a PhysicsGhostObject. Ghost objects automatically follow their spatial and detect collisions. The attached ghost itself is invisible and non-solid (!) and doesn’t interfere with your game otherwise, it only passively reports collisions.
edit: and even bolded text that is your answer.
1 Like
nnpa
March 9, 2023, 9:45am
10
it means ghost control is not solid and you need to look for another way so that the characters do not go through?
then lets again follow wiki:
You can leave the GhostControl non-solid and invisible and attach it to an (invisible) Node in the scene to create something like a motion detector. But a GhostControl also works fine when added to spatials that are solid (with RigidBodyControl) and visible (with Geometry). One use case for GhostControls is to check for collisions among CharacterControls when the characters are walking.
first sentence of bolded.
Nakano
March 9, 2023, 9:49am
12
GhostControl is to test, if the shape intersects with others, for a solid objects use RigidBodyControl, CharacterControl, BetterCharacterControl or VehicleControl.
1 Like
nnpa
March 9, 2023, 9:51am
13
i user cracter control with ghost control
SphereCollisionShape sphereShape = new SphereCollisionShape(1.2f);
playerVisual.characterControl = new CharacterControl( sphereShape , 1.2f );
playerVisual.spatial.addControl(playerVisual.characterControl);
playerVisual.characterControl.setPhysicsLocation(new Vector3f(0,0.1f,0));
rootNode.attachChild(playerVisual.spatial);
GhostControl gc = new GhostControl(sphereShape);
gc.addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
playerVisual.spatial.addControl(gc);
physics.getPhysicsSpace().add(gc);
rootNode.attachChild(playerVisual.spatial);
how to make them hard?
nnpa
March 9, 2023, 9:52am
14
how to make CharacterControl solid?
code from Wiki with CharacterControl:
Walking Character
one of 6 lines seems answer of mistake you have in code.
// Load any model
Node myCharacter = (Node) assetManager.loadModel("Models/myCharacterModel.mesh.xml");
rootNode.attachChild(myCharacter);
// Create a appropriate physical shape for it
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
CharacterControl myCharacter_phys = new CharacterControl(capsuleShape, 0.01f);
// Attach physical properties to model and PhysicsSpace
myCharacter.addControl(myCharacter_phys);
bulletAppState.getPhysicsSpace().add(myCharacter_phys);
1 Like
nnpa
March 9, 2023, 10:03am
16
remade
SphereCollisionShape sphereShape = new SphereCollisionShape(1.2f);
playerVisual.characterControl = new CharacterControl( sphereShape , 1.2f );
playerVisual.spatial.addControl(playerVisual.characterControl);
playerVisual.characterControl.setPhysicsLocation(new Vector3f(0,0.1f,0));
physics.getPhysicsSpace().add(playerVisual.characterControl);
rootNode.attachChild(playerVisual.spatial);
GhostControl gc = new GhostControl(sphereShape);
gc.addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
playerVisual.spatial.addControl(gc);
physics.getPhysicsSpace().add(gc);
SphereCollisionShape sphereShape = new SphereCollisionShape(2.0f);
CharacterControl myThing_phys = new CharacterControl( sphereShape , 1.2f );
model.addControl(myThing_phys);
monster.control = myThing_phys;
physics.getPhysicsSpace().add(myThing_phys);
GhostControl gc = new GhostControl(sphereShape);
gc.addCollideWithGroup(PhysicsCollisionObject.COLLISION_GROUP_01);
model.addControl(gc);
physics.getPhysicsSpace().add(gc);
but they are still not solid.
ok, i see missing line, tho it should be solid now if its proper physics space.
I dont see all project, so mistake might be anywhere.
My next suggestion for you is to compare JME Walking Character TEST with your code.
working vs not working.
here is test (you can also run Test via SDK Test project to see how it works):
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
This file has been truncated. show original
1 Like
nnpa
March 9, 2023, 10:17am
18
it uses character control and rigged body control
and i need to make collision between character control
Why would you want to add charcterControl to a none playable Monster?
so was it a lie again? If it collide with other RigidBodies, then it is solid.
Carpenter asked a good question.