Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get space when using physics engines direct #17401

Closed
BastiaanOlij opened this issue Mar 10, 2018 · 9 comments
Closed

Can't get space when using physics engines direct #17401

BastiaanOlij opened this issue Mar 10, 2018 · 9 comments

Comments

@BastiaanOlij
Copy link
Contributor

BastiaanOlij commented Mar 10, 2018

Godot version:
Godot 3.0.2

OS/device including version:
Windows 10, but not important

Issue description:
The only way to obtain a space object is to use a physics body or area, as I'm using PhysicsServer directly to do testing not supported by the standard physics bodies. It seems a bit overdone to use those as Godot will complain of not adding any collision body nodes but as I'm using shapes directly, don't need those :)

Was talking with @AndreaCatania about adding the ability to get the main space or something like that.

Steps to reproduce:
See example once i have it uploaded

Minimal reproduction project:
This test project shows what I'm trying to accomplish:
https://www.dropbox.com/s/2wvmgddglkkg3oc/Test_teleport.zip?dl=0

In this project have a look at the Function_Teleport.tscn file, you'll see that the root node is a Kinematic Body but there really is no use for it to be a Kinematic Body

Looking at Function_Teleport.gd line 101 - 102, those 2 lines of code obtain the direct state object needed to perform the collision checks I'm doing. To be able to do var space = PhysicsServer.body_get_space(self.get_rid()) I need this node to be a kinematic body.

@bojidar-bg
Copy link
Contributor

Can't you use get_viewport().find_world[_2d]().direct_space_state to get the space of the parent viewport?

@AndreaCatania
Copy link
Contributor

Can't you use get_viewport().find_world_2d.direct_space_state to get the space of the parent viewport?

I think that we should create a specific function that does it internally

@BastiaanOlij
Copy link
Contributor Author

@bojidar-bg I didn't know that, I'll try that tonight!

@AndreaCatania it would be nice as its not a clear step to take

@TGRCdev
Copy link
Contributor

TGRCdev commented Oct 4, 2018

This has been fixed by PhysicsDirectBodyState.get_space_state(), hasn't it?

EDIT: Oct 17, 2019
This is wrong and completely unrelated to the actual issue. My mistake.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 13, 2019

@BastiaanOlij Could you confirm the above comment?

@BastiaanOlij
Copy link
Contributor Author

Owh, I have to find some time this weekend to see if I can verify that claim. If it does that would be splendid.

@TGRCdev
Copy link
Contributor

TGRCdev commented Oct 17, 2019

Doesn't get_viewport().find_world().direct_space_state do what you need?

@AndreaCatania
Copy link
Contributor

Yep, but the idea is to: #17401 (comment)

@madmiraal
Copy link
Contributor

Closing this issues, since get_viewport().find_world().direct_space_state works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants